Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Flow Designer Script Check if variable is null

jaubert
Tera Guru

In all transparency, I am not great at scripting.  I am using the scripting function in flow designer and I need help checking if my variables are null.  if they are not null I would like the workflow to go to the next step.  Below is where I started and I got stuck, please assist in any way possible.  

 

var candidateFound = fd_data.trigger.request_item.variables.candiate_found.getDisplayValue();
var cityLocation = fd_data.trigger.request_item.variables.city.getDisplayValue();
var stateLocation = fd_data.trigger.request_item.variables.u_state.getDisplayValue();
var startDate = fd_data.trigger.request_item.variables.start_date.getDisplayValue();

if ((candidateFound == null) && (cityLocation == null) && (stateLocation == null) && (startDate == null)); {


  return false;
   
}
 
I am assuming if it returns true then it will proceed to the next step.

 

Thanks,

 

Jewell

1 ACCEPTED SOLUTION

No worries, once you select an Item from the Conditions, the variable option appears in the condition. 

JamesChun_1-1714683608330.png

I confirmed the functionality works in my PDI but noticed that it does take a minute or two for the Flow to detect that the variables have been updated.

 

FYI, in the previous script, there is a semi-colon that should be deleted

if ((candidateFound) && (cityLocation) && (stateLocation) && (startDate)); {

View solution in original post

3 REPLIES 3

James Chun
Kilo Patron

Hi @jaubert,

 

You can do this without any code at all.

  • Add Get Catalog Variables from Acess, and populate them as something like the below. Make sure you select all the variables needed

JamesChun_0-1714509276303.png

  • Use 'IF' flow logic to check if the variables from the previous step are empty or not.

    JamesChun_1-1714509329565.png

     

If you are keen on the script, something like the following will do:

 

var candidateFound = gs.nil(fd_data.trigger.request_item.variables.candiate_found);
var cityLocation = gs.nil(fd_data.trigger.request_item.variables.city);
var stateLocation = gs.nil(fd_data.trigger.request_item.variables.u_state);
var startDate = gs.nil(fd_data.trigger.request_item.variables.start_date);

if ((candidateFound) && (cityLocation) && (stateLocation) && (startDate)); {
    return false;
} else {
    return true;
}

Note that this will return false when ALL variables are empty.

 

Cheers

Thank you for your response.  If I use the no code solution proposed will this also allow me to pause until the variables are no longer empty?  The "wait for condition" only allows me to select a table that is why I was using the script.

 

jaubert_0-1714656003925.png

 

No worries, once you select an Item from the Conditions, the variable option appears in the condition. 

JamesChun_1-1714683608330.png

I confirmed the functionality works in my PDI but noticed that it does take a minute or two for the Flow to detect that the variables have been updated.

 

FYI, in the previous script, there is a semi-colon that should be deleted

if ((candidateFound) && (cityLocation) && (stateLocation) && (startDate)); {