How do you deal with this situation? I’d rather not have to leave the value at ‘(none)’ and force the user to select the one and only possible value.
Accepted AnswerJeff MalinOffline0I think I posted on this a while back but can't seem to find it, basically you need to have the change callback on the first field spawn a custom event listener (use setInterval/clearInterval to build one) which wait until the value of the second field is set by SBM after it gets the dependent values. You can watch the field directly, or listen for the value of parent.madeRequest, which is set to 1 but will will go back to 0 when the callback is finished.
I think I already put an enhancement request out there for the SBM JS API to make AddChangeCallback work right on dependent fields, by looking into their driving field and making an additional hook into its callback that's triggered when the APFRequest (SBM's version of an AJAX callback) completes. This works around the issue, as you've found, that change events in browsers fire when a change is made by the user directly on an object, but not when the object is changed by a script.
Accepted AnswerDerekOffline0Thank you, this is the response i received from Serena but it doesn't seem to work...at least not with relational fields. By chance, do you have any examples of your code? And was it with relational fields or something else?
It sounds as though there are two solutions available. Here are some example scripts from a related case.
You can manually set the FireChangeEvent:
var gpmField = GetFieldByName("GPM_UNIT");
SetFieldValue("GPM_UNIT", "PCCM", false);
which will not automatically attach the onchange event or to:
SetFieldValue("GPM_UNIT", "PCCM", true);
and then you will not need to manually fire the FireChangeEvent.
One of these should resolve your issue, provided the field is not relational. Relational fields and their interaction with the firechangeevent may be repaired through the defect linked earlier.
Accepted AnswerNeal BoswellOffline0I can't get the workaround to work, and DEF210025 isn't fixed in R10.1.1.1 so I'm stuck.
I have very simple JS to read a field and set the value of a relational field. This works. However, the subrelational field based on that relational field never gets populated. I've tried everything I can think of in JS and in Form Actions but Change Event never gets fired.