- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 11:45 PM
Hi Team,
I am working on a workflow part to skip the approvals based on RITM string value. Below the process.
We will create a SOW request through the sc_task. Here, i have to skip the approval based on the given value from RITM variable.
i have variable solution center (Single line text) Here based on the value i should skip the approval. If users give only "Rollouts" then approvals should be skipped in the workflow.
The workflow is in sow module table. So i am using below script gliding the sc_req_item table and trying to set YES / NO in IF condition. But this is not working.
answer = ifScript();
function ifScript() {
var gr1 = new GlideRecord('sc_req_item');
gr1.addQuery('sys_id', requesteditem);
gr1.query();
if (gr1.next()) {
var solutioncenter = gr1.variables.u_solution_center;
gs.log('solutioncenter' + solutioncenter, 'a360879');
if (solutioncenter == "Rollouts") {
return 'yes';
}
else {
return 'no';
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 01:11 AM
Hi,
you didn't share this info
in your script you have not defined what does the variable requesteditem holds?
are you sure it holds RITM sysId
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 11:55 PM
Hi in your script requesteditem is not defined any where hence the error
answer = ifScript();
function ifScript() {
var gr1 = new GlideRecord('sc_req_item');
gr1.addQuery('sys_id', requesteditem); //requesteditem is not defined any where hence the error
gr1.query();
if (gr1.next()) {
var solutioncenter = gr1.variables.u_solution_center;
gs.log('solutioncenter' + solutioncenter, 'a360879');
if (solutioncenter == "Rollouts") {
return 'yes';
}
else {
return 'no';
}
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 11:55 PM
Hi,
in your script you have not defined what does the variable requesteditem holds?
are you sure it holds RITM sysId
Also ensure you compare with this rollouts in case user types in lower case
answer = ifScript();
function ifScript() {
var gr1 = new GlideRecord('sc_req_item');
gr1.addQuery('sys_id', requesteditem); // requesteditem what this holds?
gr1.query();
if (gr1.next()) {
var solutioncenter = gr1.variables.u_solution_center;
gs.log('solutioncenter' + solutioncenter, 'a360879');
if (solutioncenter == "Rollouts" || solutioncenter == "rollouts") {
return 'yes';
}
else {
return 'no';
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 11:59 PM
Hi Ankur,
Thanks for your response. Yes i checked this in background script. I can see its working, but in workflow this is always setting NO.
At the top of the script i have added this line. I missed to update in my 1st post. Please find the attachment.
var requesteditem = current.variables.u_ritm_no;
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 01:11 AM
Hi,
you didn't share this info
in your script you have not defined what does the variable requesteditem holds?
are you sure it holds RITM sysId
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader