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
11-17-2021 11:05 PM
Hi Annie
Try this
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.sys_id;
}
return ag;
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2021 11:15 PM
this should work fine
var ritmSysId = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);
var product = rec.variables.product;
var group = new GlideRecord('sys_user_group');
group.addEncodedQuery('nameSTARTSWITHCLD - SaaS^nameLIKE' + product);
group.query();
if (group.next()) {
ag = group.getUniqueValue();
}
return ag;
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-18-2021 12:43 PM
This is slightly better than what I have, as it doesn't give me the error about 'current' when I try to activate the flow. But it doesn't set the assignment group properly on the task. Maybe my logic elsewhere is bad. I did double-check the variable name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2021 08:38 PM
Hi,
Sure do share the updates.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader