How to debug a workflow script?

praveenKumar2
Kilo Expert

Hi All,

I have written a workflow script and it doesn't seem to work as per the design. 

Requirement : On a catalog request there are several checkboxes which the user chooses and rehire is one of the option. So when the user selects rehire on the catalog and submits the request the workflow is triggered, in the workflow there is a IF condition to validate if the requested for has rehire checkbox as true on his user profile and if yes it has to create a task and if it is no it has to end the workflow. How many ever times i try it always gets the answer as no. Below is the script i have written on the If Condition.

answer = ifScript();
function ifScript() {
var Usr = current.variables.o_employee;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',Usr);
gr.query();
while(gr.next()){

if (gr.u_rehire == 'true'){
return 'yes';
}
else
{
return 'no';
}
}}

 

Let  me know if someone has a solution to this script.

 

Thanks,

pK.

1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

Looks like it should work as long as o_employee is a reference filed.  Try removing the single quotes around true in your if statement.  Also why are doing a while (gr.next()) instead of if (gr.next)?

View solution in original post

5 REPLIES 5

Unser system log you will find script log statements. This is where you will find the output.