Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to add SC Catalog item variable into description if a certain value was input into the field?

Joel KP
Tera Contributor

Hello community, 

Using Flow Designer, how does one go about having a SC Catalog item variable, populate into the TASK description IF a specific value was chosen in the variable field?

 

I'm not sure how, using the "if" logic (if that's even the proper route)

 

The variable type is a Select Box with options ranging 0-10.

 

The goal is anything 1 or above would populate "Test" into the description. If it's 0, it would not populate.

 

TYIA.

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Joel KP 

in the catalog task action you can use inline script and handle it

if(parseInt(fd_data.trigger.request_item.variables.variableName) > 0){
	return 'Test';
}
else{
	return '';
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Joel KP 

in the catalog task action you can use inline script and handle it

if(parseInt(fd_data.trigger.request_item.variables.variableName) > 0){
	return 'Test';
}
else{
	return '';
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you so much @Ankur Bawiskar.

 

One more question if I may - If I wanted this done with not 1 but 2+ variables, how would I tie the 2+ scripts to run together.

 

Would I simply copy the script a second time and change the variable?

 

E.g. 

if(parseInt(fd_data.trigger.request_item.variables.variableName1) > 0){
    return 'Test1';
}
else{
    return '';
}

if(parseInt(fd_data.trigger.request_item.variables.variableName2) > 0){
    return 'Test2';
}
else{
    return '';
}

Naga Ravindra R
Kilo Sage

Hi @Joel KP 

 

When the catalog item/ record producer is submitted, the variable values will be stored in question_answer table.

 

May be you can have a action to look up the variable value for the submitted record and have your if logic and perform the next operations.