on 2012 Apr 11 9:53 AM
Hi,
I have an extension field with an VLV & Text. I need to reset the value to defaults for VLV & Text. I tried using the below syntax
doc.getExtensionField("XXXX").set(null);
This has resulted in VLV field disappeared from the screen & the Text value remains as entered.
Please suggest
Rgds,
Vinod
Request clarification before answering.
Hi Vinod,
I have faced this before. Please try the following syntax .
doc.getFieldMetadata("FIELD_NAME").set(doc,null);
I hope it will solve your problem.
Thank you,
Noppong Jinbunluphol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi apologies to hijack this thread but seemed similar to my issue, just a bit different,
Also have the same issue, except my scenario is on a Toolbar script and on a MasterAgreement context (1004).
Issue is when I try to create an new object reference to set to a null valuelistvalue value for a lineItem that I had just added to the master agreement I get the following error:
ClassCastException:Illegal cast. Cannot cast com.frictionless.common.db.ObjectReference to com.frictionless.api.common.types.LocalizedObjectReferenceIfc.
I need to set Item_Cat field in a lineItem to a certain default value depending on certain conditions.When I call the IBeanFieldMdIfc.get() method I get com.frictionless.api.common.types.LocalizedObjectReferenceIf and it is only logical to use the same type when you try to set it some value. Right?
Here is what I do when this generates an error.
IBeanFieldMdIfc itemCat = (IBeanFieldMdIfc)lineItem.getFieldMetadata("ITEM_CAT");
LocalizedObjectReferenceIfc locObjRef = (LocalizedObjectReferenceIfc)itemCat.get(lineItem);
This shows me the displayed value in the vlv dropdown if the lineItem already exists and null if the lineItem is new.
Now I try to set the new lineItem vlv value like this:
com.frictionless.api.common.types.TypeFactory fact = new TypeFactory();
objectID = -2147482685;//getObjectId("custom$Service", "Item Category");
objRef = fact.createObjectReference(616, objectID,"Service");
itemCat.set(lineItem, objRef);// This line generates a ClassCastException:Illegal cast. Cannot cast com.frictionless.common.db.ObjectReference to com.frictionless.api.common.types.LocalizedObjectReferenceIfc.
Notice the two different package names, question where the hell does CLM get the com.frictionless.common.db.ObjectReference because it does not even get imported into the script.
I am now confused please assist.
Hello,
The item category attribute is a localized object reference, which you have correctly identified in your code that gets the value. However, in your attempt to set a new value you are simply creating an object reference, not a localized object reference. Hence you are getting a class cast exception. Please take a look at TypeFactory.createLocalizedObjectReference(int, int, String).
Hope that helps.
Thanks
Hi Vinod,
We had faced this issue earlier. This approach is not fail safe.
A better approach would be to create a new object reference of VLV class using TypeFactory APIs. Since this is a new object reference, it points to null (None) by default.
You should then use this object reference to set the extension VLV, i.e., replace null by this new object reference in your assignment statement.
doc.getExtensionField("XXXX").set(null);
Thanks
Devesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinod,
The syntax looks right to me. How is your script getting triggered? Do you see anything in the logs?
Regards,
Vikram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.