The first call to the JS function getIdentityAccess() in Field > Script > Source works.
The second call in Field > Attributes > Map > entry > value > Script > Source doesn’t. It throws “Command Not Found” error.
Both the “Field > Scripts” and “Field > Attribute > entry > Scripts” have access to the entire Form via a variable called “form”. Therefore they have access to any other Field in the Form. You can declare a hidden Field and initialize its value with some common value that you intend to reuse, and get that value in any block:
Object val = form.getField(“myHiddenField”).getValue();
But if I need to get form field as a boolean, I will need to do something like this:
Field f = form.getField("booleanField1");
if (f != null) {
Object o = f.getValue();
if (o != null) {
return (Boolean) o;
}
}
return defaultValue;
I’d rather have that in a rule library and reference it, than copy-pasting a blob of code everywhere.
e.g. I have a checkbox that will decide if 50 other fields is displayed or not. Think of amount of code to calculate the hidden attribute of these 50 other fields.
I’m not 100% sure if that will work, but worth a try. I understand your pain though when it comes to complex Forms. What I typically do for this, and it may be a workaround if you cannot get the Script includes to work, is to use a rule with the following syntax:
Workflow objects can become huge with scripts, allowed value lists, etc. so I typically just throw these rules on every Field and then have a Custom object that holds particular settings on how the Form should function.
I already have RuleLibrary defined at Workflow level, that’s how Field > Script > Source can use my JS functions.
The rule workaround involves managing a bunch of additional rules, but at least the rules can refer to the same RuleLibrary, and the form can be tidier.