AnsweredAssumed Answered

Check if attachment field is null

Question asked by gbanks on Jul 21, 2017

I am implementing a JavaScript that performs operations when specific form attachments exist. If that particular field has no attached documents, I don't need to perform that function.However, as I'm trying to do an if comparison, I am getting the same results between fields where 1 is attached and the other is not. This occurs regardless of whether I compare it to "" or null. Something interesting, with "" they both enter the if statement and using null neither do. What can I do to differentiate between an actual file attached and a null attachment?

 

Here is my JS, i've included both the null and "" examples in case anyone wants to easily replicate:

 

if (execution.getVariable('upload_1') !==  null) {
   //do something

}

if (execution.getVariable('upload_1') !==  "") {
   //do something

}

if (execution.getVariable('upload_2') !== null) {
   //do something
}

if (execution.getVariable('upload_2') !==  "") {
   //do something

}

 

Outcomes