Trying to add a JS for hiding/showing fields based on condition. I'm getting an error message, even though i have the 'pass execution as first context checked and the web resource is on the 'OnLoad' of the form. Any ideas on what could be the issue?
If fieldNumber is null = show field 2
if fieldnumber not null, show field 1
function hideshowSerialNumberFields(executionContext) {
var formContext = executionContext.getFormContext();
//Getting value from Number
var fieldNumber= formContext.getAttribute("field_number").getValue();
//If Number = Blank, Show Serial Numbers and hide Serial Number
if (fieldNumber === null) {
formContext.getControl("field_1").setVisible(false);
formContext.getControl("field_2").setVisible(true);
}
else {
formContext.getControl("field_1").setVisible(true);
formContext.getControl("field_2").setVisible(false);
}
}

Report
All responses (
Answers (