on 07-08-2015 9:52 AM
Hi
i have to set "no" value to some select fields via Script.
i do something like this:
ValueListTypeIBeanIfc wflValue = findByExternalId("WFL Section Validation");
ValueListValueIBeanIfc wflNoValue = wflValue.getCollnValueListValue().get(1);
logInfo("wflNoValue: " + wflNoValue.toString());
doc.getExtensionField("ZCLM_CRM_HOLD").set(wflNoValue.getLocalizedObjectReference());
after executing this the field is set to "Select...".
the vlvObjRef.toString() show me the correct value: -2147482215:616:No
so i have no clue what i'm doing wrong...
can you help me with this?
thank you
Waldemar
Hello Waldemar,
Please find below a correct code snippet for setting a VLV value:
import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeIfc;
import com.sap.odp.api.ibean.IBeanHomeLocator;
vlvHome = IBeanHomeLocator.lookup(session, ValueListValueIBeanHomeIfc.sHOME_NAME);
doc.getExtensionField("ZCLM_CRM_HOLD").set(vlvHome.findUniqueByNameType("No", 100603).getObjectReference());
The spec for method: findUniqueByNameType(java.lang.String sValue, int nTypeCode)
sValue - Value List Value Display Name ID
nTypeCode - Value List Type Internal ID
Values provided in code snippet are from my system. Please change to your required values.
Please also note that depending on Script type you may or may not be required to trigger a .save() on the doc.
Regards,
Bogdan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Bogdan,
thank you for your answer.
your code snipplet is unfortunately also not working for me
vlvHome = IBeanHomeLocator.lookup(session, ValueListValueIBeanHomeIfc.sHOME_NAME);
doc.getExtensionField("ZCLM_CRM_HOLD").set(vlvHome.findUniqueByNameType("No", 1039).getObjectReference());
i should set all questions to "no" when the master agreement is duplicated.
so i execute my script on the master agreement lifecycle event "duplicate".
as you can see in the picture below, the fields have after that the value "select.."
when i add the method doc.save() at the end of the script i get an error.
our value list types definition is as follow:
regards
Waldemar
Hello Waldemar,
That is very strange, because I am using the same script target (Duplicated) and it works fine. For Duplicated script you do not want to save the doc in the script.
Please share your Sourcing system version and patch level and check:
Regards,
Bogdan
Hello Bogdan,
you was in right. an other programmer was override the value befor saving the contract.
it works now correctly.
both solutions; mine and yours
i have an another question arroud this theme:
i am trying to do the same on the "Field Data Edit" event of Question1.
e.g. if the Question1 was switched to "yes" then Question2 should change "on the fly" (without saving) the Value to "no".
so i do something like this:
if (newFieldValue.getDisplayName().equals(VAL_YES)) {
logInfo("ZCLM_WFL_002 value before: " + doc.getExtensionField("ZCLM_WFL_002").get().getDisplayName());
vlvHome = IBeanHomeLocator.lookup(session, ValueListValueIBeanHomeIfc.sHOME_NAME);
doc.getExtensionField("ZCLM_WFL_002").set(vlvHome.findUniqueByNameType("No", VALUE_ID).getObjectReference());
logInfo("ZCLM_WFL_002 value after: " + doc.getExtensionField("ZCLM_WFL_002").get().getDisplayName());
}
when i look in the log files then i can see that the value was changed to "no". but on the screen after the screen was refreshed i can see still the old value in Question2 select field. do i have to do something like save or persist the new field value?
Thanks
Waldemar
Hi Waldemar,
It's good that the setter worked, I was afraid of some other bug CLM has in V9 SP14.
For the dependent VLVs, there are a few comments:
What happens in CLM is that the FDE script is not actually executed when the Q1 value is set, but when the page is refreshed (tab-change). Some fields (aka Currency) have built-in auto-refresh, but not the extension fields.
This is a big limitation everyone is hitting, and I have seen a promise from SAP that V10SP6 will include a PageCusto that you can set to have 'auto-refresh' on any field you like. Only then you will be able to have 'live' dependent fields.
Bogdan
Hi Bogdan,
thank you for your explanations.
i'm also a big fan of efficiency so i choose as well your code
i'm working with
Application Version: 10.0.06.00 build 253628
Schema Version: 10.0.06
after changing the tab the value in question2 is not changing to the expected value.
I can observe the following sequence of events:
1. when i choose in Question1 the value "yes" the "Field Data Edit" event is fired.
2. the script is changing the value of Question2 field to "no"
3. i can see it in my log file: value before: "Yes" - value after: "No"
4. after that, the system refresh the page itself.
5. i can see that the value in Question2 on the screen was not changed.
if i do it immediately again (without page refresh/reload myself) and set the value in Question1 again to "yes" i get exactly the same output in log file: value before: "Yes" - value after: "No"
it seems that some event is setting the value of Question2 back to the original value after i was changing it via Beanshell to "no".
i have no idea what i can do with this...
we need a questionnaire that interact with the user before we save the master agreement.
maby someone had a similar problem
regards
Waldemar
Hi Bogdan,
after we talked with SAP, we get the statement that this behaviour ist normally. the self defined fields will not be refreshed after change from script. SAP also not planned to chage this behaviour.
the only way to do what i want is over the validation with rules designer.
regards
waldemar
Hello Waldemar,
Try below code and check
import com.sap.odp.api.doccommon.masterdata.ValueListTypeIBeanHomeIfc;
sMA_YES/NO_VLV = "z_yes_no";
vlvTypeHome = IBeanHomeLocator.lookup(session, ValueListTypeIBeanHomeIfc.sHOME_NAME);
vlvType = vlvTypeHome.findByExternalId(sMA_YES/NO_VLV);
vlvColl = vlvType.getCollnValueListValue();
vlvItr = vlvColl.iterator();
while(vlvItr.hasNext()){
member = vlvItr.next();
if(member.getDisplayName().equalsIgnoreCase("Yes")){
memberName= member.getLocalizedObjectReference();
doc.getExtensionField("Z_MA_COMPETITIVE").set(memberName);
}
}
Inorder to set the fields which are of Value list value types, you have to use the localizedObjectReference for that specfic values and then use in your code.
Regards,
Raj
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.