- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 03:19 PM
Hi all,
I am trying to get an yes or no answer on my workflow based on a list collector values, which are reference from a custom table.
What I need to achieve is to identify the values selected in the list collector and based on these values do something like dot walking to get which change group is related to that value in the table.
This is my script, but so far does not return any value, can someone help me and put me in the right direction?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 03:06 AM - edited 08-23-2024 10:50 AM
The next step is to temporarily add some log lines to the script so you can see what is happening. It also sounds like this would be better with a more conventional approach - return all of the list collector records, then test each for the condition match. Also, I shouldn't have used 'answer' as a script variable since it is already a part of the if activity.
answer = ifScript();
function ifScript() {
var collector = current.variables.my_variable.toString(); //get variable name from catalog item
workflow.info('collector = ' + collector); //verify the variable was retrieved
var gr = new GlideRecord('my_custom_table'); //access the custom table that store the values from List collector
gr.addQuery('sys_id', 'IN', collector);
gr.query();
while (gr.next()) {
workflow.info('Record found ' + gr.sys_id + ' Group = ' + gr.u_change_group); //change this to a more descriptive field on the custom table
if (gr.getValue('u_change_group') == 'dcfb023edb4d1340439d14a05b9619c5') { //define the change group with sys_ID
workflow.info('Group matched');
return 'yes'; //stop running the script when the first group match is found
}
}
workflow.info('No list collector record had a matching group');
return 'no'; //if no groups matched, take the No path
}
Be sure to test this workflow change with a newly-submitted record. You can view these logs on the Log tab while viewing the context from the Related Link at the bottom of the RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 07:00 AM