flow designer script the assignment group based on a catalog variable chosen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2021 11:01 AM
for 'Create Catalog Task' action in my flow, I have scripted the Assignment Group as one that has a name that starts with 'CLD - Saas' and contains the name of the product variable:
var ag = fd_data.trigger.current.assignment_group;
var product = fd_data.trigger.current.variables.product;
var group = new GlideRecord('sys_user_group');
group.addEncodedQuery('nameSTARTSWITHCLD - SaaS^nameLIKE' + product);
group.query();
if (group.next()) {
ag = group;
}
return ag;
but when I try to activate the flow it gives me an error about not being able to use 'current'.
What am I doing wrong?
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 10:56 PM
Hi
I just tried to adapt your script for my needs but receiving the message
Error: "ag" is not defined.,Detail: "ag" is not defined.
when executing.
var ritmSysId = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);
var product = rec.variables.region;
var group = new GlideRecord('sys_user_group');
group.addEncodedQuery('nameSTARTSWITHIntune Keyuser ' + product);
group.query();
if (group.next()) {
ag = group.getUniqueValue();
}
return ag;
Any idea on this?
Thanks in advance!
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 11:23 PM
Hi,
your encoded query seems wrong
group.addEncodedQuery('nameSTARTSWITHIntune Keyuser ' + product);
Ensure you use correct query to search
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
09-08-2022 01:25 AM
Thanks for the advice!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 06:02 AM
Glad to help.
Please mark response helpful as well.
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
11-17-2021 11:21 PM
Hi,
Simply update your script as below and should work:
var ag;
var product = fd_data.trigger.current.variables.product;
var group = new GlideRecord('sys_user_group');
group.addEncodedQuery('nameSTARTSWITHCLD - SaaS^nameLIKE' + product);
group.query();
if (group.next()) {
ag = group.sys_id;
gs.info('Value of Group is ' + ag);
}
return ag;
In case if it still does not works, check what is coming in Log Statement which I have given above.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
