The CreatorCon Call for Content is officially open! Get started here.

If script to check if List Collector variable is empty

Harry Campbell2
Mega Guru

Hello All,

I have created an if condition in my workflow script to check of a list collector variable is empty but it seems to be returning 'yes' whether the collector is empty or not.

This is the script:

answer = ifScript();
function ifScript() {
var AdditionalApps = current.variables.additional_apps.toString(); //convert the variable list to string
var arrayList = AdditionalApps.split(",");
   if (arrayList.length > 0) {


             return 'yes';
   } else {
           return 'no';
         }
}

Could anyone shed any light on why this might be happening?

1 REPLY 1

Prateek Gupta3
Mega Guru

Hi,

 

If you try by printing the length of arra, it will return 1. Therefore it is failing.

Rather than this try by checking if the value "current.variables.additional_apps.toString()" is equal to NULL.

 

Thanks,

Prateek Gupta