Query a table - workflow - if condition

Sue143
Tera Expert

Hello, 

I need to query a table according the user's answer on the request, but up to now I was not successful, can somebody help me to right a script that can query the table according reference field on the Catalog item? 

Specifically, the user needs to select on the reference field of the catalog item the name of desired software to be uninstalled. There are more than 100 selectable choices, and according the user's answer I have to create a if condition on the workflow.

and the IF statement should be something like:

If the 'selected software' of 'variable' needs a 'license' and 'license is central', return YES than create a task to 'specific group name', if return NOT create a task to 'service desk'.

 

Thank you.

1 ACCEPTED SOLUTION

Hi Suellen,

If my answer solved your query then please mark it correct as well. So that this question can go away from unanswered queue and others can get benefited from the same.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

View solution in original post

2 REPLIES 2

Mohit Kaushik
Mega Sage
Mega Sage

You can create an if activity and write a script there as below:

 

Based on the result of your if activity, you can create task by using create catalog task activity and attach it yes and no responses.

answer();

function answer(){

var soft = new GlideRecord('software table name');

soft.get(current.variables.u_selected_software); // in place of u_selected_software provide the name of the variable.

if(soft.licence=='central')

{

return 'yes';

}

else

return 'no';

}

Please mark this correct and helpful based on the impact.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi Suellen,

If my answer solved your query then please mark it correct as well. So that this question can go away from unanswered queue and others can get benefited from the same.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)