In LiveCycle/Forms Designer PDF, script breaks if 'resolveNode' is used on path that doesn't exist (null). How to remove paths that are no longer valid from scripts in entire form?
It looks like the 'LiveCycle' community is archived so I posted this here. If this should go elsewhere please let me know.
I inherited a LiveCycle PDF that has about 1,600 instances of 'resolveNode' in the scripts used throughout the form. In debugging the form I've noticed that many script events are failing prematurely and silently. It seems to me that this is happening because 'resolveNode' is being used on som expressions/paths that no longer exist within the document and are returning 'null'.
Is there a way to make the form continue running scripts if 'resolveNode' is used on a null path?
If not, is there an easy way to find all the instances of 'resolveNode' that are null? The only (sort of) reasonable thing I've thought of is extracting all 1,600 resolveNode expressions, putting them in an array, and using something like the below function to make a list of every one with a null value, then removing those lines manually. Is there any other option?
const fieldsArray = ["form1.Page1.field1","form1.Page1.field2"];
for (i = 0; i < fieldsArray.length; i++) {
if (xfa.resolveNode(fieldsArray[i]) == null){
console.println("Null field: " + fieldsArray[i]);
}
}
Edit: Also worth mentioning, this is the type of script that is failing prematurely. I'm not sure why trying to set the access property of a null field would result in the rest of the script breaking, but that's the behavior I'm seeing:
//This script is bound to the click event of a checkbox
this.resolveNode("form1.Page1.field1").access = "readOnly"; //For this example, this field exists and the access property is set properly.
this.resolveNode("form1.Page1.field2").access = "readOnly"; //This field does NOT exist and returns null. As a result the following lines of this script do not run
this.resolveNode("form1.Page1.field3").access = "readOnly"; //This line does not run due to the null issue in the line above
