- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 05:49 AM
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';
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 05:57 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 06:25 AM
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';
}
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 05:57 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 06:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 06:25 AM
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';
}
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 06:26 AM
found it, value was failed and not fail
thanks!