if script in workflow to check value

jean-pauldehaas
Tera Guru

Hi,

 

i have a workflow that is running on the story table with an if condition, the if script should check a field value on the rm_scrum_task table and depening if its Pass or Fail it should follow the selected path in the workflow.

for some reason it keeps returning No even if the result is different.

 

whats wrong with my script here:

 

answer = ifScript();

function ifScript() {
var scrumtask = new GlideRecord('rm_scrum_task');

scrumtask.addQuery('parent', current.sys_id);
scrumtask.query();

if (scrumtask.test_result == 'Fail')

return 'yes';

else

return 'no';

}

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@jean-pauldehaas 

you forgot to use next method

I hope you are comparing correct value for Fail

answer = ifScript();

function ifScript() {
var scrumtask = new GlideRecord('rm_scrum_task');
scrumtask.addQuery('parent', current.sys_id);
scrumtask.query();
if(scrumtask.next()){
if (scrumtask.test_result == 'Fail')
return 'yes';
else
return 'no';
}
}

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

@jean-pauldehaas 

are you sure the field name is correct?

are you sure the value you are comparing is correct i.e. it's Fail or fail

try to print the value and see

answer = ifScript();

function ifScript() {
var scrumtask = new GlideRecord('rm_scrum_task');
scrumtask.addQuery('parent', current.sys_id);
scrumtask.query();
if(scrumtask.next()){
gs.info("Value of test result" + scrumtask.test_result);
if (scrumtask.test_result == 'Fail' || scrumtask.test_result == 'fail')
return 'yes';
else
return 'no';
}
}

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

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@jean-pauldehaas 

you forgot to use next method

I hope you are comparing correct value for Fail

answer = ifScript();

function ifScript() {
var scrumtask = new GlideRecord('rm_scrum_task');
scrumtask.addQuery('parent', current.sys_id);
scrumtask.query();
if(scrumtask.next()){
if (scrumtask.test_result == 'Fail')
return 'yes';
else
return 'no';
}
}

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

Hi ankur,

 

thanks i think this should work but untill now its still returning no so something is wrong in my 2nd IF but what is the question

@jean-pauldehaas 

are you sure the field name is correct?

are you sure the value you are comparing is correct i.e. it's Fail or fail

try to print the value and see

answer = ifScript();

function ifScript() {
var scrumtask = new GlideRecord('rm_scrum_task');
scrumtask.addQuery('parent', current.sys_id);
scrumtask.query();
if(scrumtask.next()){
gs.info("Value of test result" + scrumtask.test_result);
if (scrumtask.test_result == 'Fail' || scrumtask.test_result == 'fail')
return 'yes';
else
return 'no';
}
}

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

found it, value was failed and not fail

 

thanks!