- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2025 02:03 AM
I'm using the below script in assignment group field of catalog task in Flow designer for fetching the assignment group. The v03_work_group & v05_affected_cis are single line text variables and are non mandatory.
When I'm giving no input to those end user variables, then the assignment group is getting populated in task according to the requested for user's request management group.
Also its getting populated when I'm giving a valid assignment group name which is under requested for users company domain for v03_work_group.
But its not getting populated when I'm giving a valid assignment group name which is not under requested for users company domain or when I'm giving an invalid name for v03_work_group.
The goal is the assignment group which I'm giving for v03_work_group should be populated in assignment group if its a valid group despite of the domain. If I'm giving any invalid entry then only it should get assigned to requested for user's request management group.
What changes should I make in the script? Is it a limitation of flowdesigner ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2025 03:07 AM - edited 07-16-2025 03:48 AM
Hi @SumajRajNk,
I see that if group name is not empty it executes a glide record for garbage value too. You need to remove first if condition and do a GlideRecord check, if GlideRecord is not returned, then do other checks, also keep else condition as fallback so that assignment group returns Service Management group.
Bonus: add queryNoDomain() for cross domain assignment.
Try this script:
var groupName = fd_data._1__get_catalog_variables.v03_work_group.toString();
var ciName = fd_data._1__get_catalog_variables.v05_affected_cis.toString();
var assign_group = "";
var groupGR = new GlideRecord('sys_user_group');
groupGR.addQuery('name', groupName);
groupGR.queryNoDomain();
if (groupGR.next()) {
assign_group = groupGR.sys_id.toString();
return assign_group;
}
else if (ciName != "") {
var ciGR = new GlideRecord('cmdb_ci');
ciGR.addQuery('name', ciName);
ciGR.addQuery('managed_by', '!=', '');
ciGR.queryNoDomain();
if (ciGR.next()) {
assign_group = ciGR.managed_by.toString();
return assign_group;
}
} else {
var requestedFor = fd_data.trigger.request_item.request.requested_for;
if (requestedFor && requestedFor.company) {
var atdGR = new GlideRecord('u_account_team_directory');
atdGR.addQuery('u_company', requestedFor.company.toString());
atdGR.queryNoDomain();
if (atdGR.next() && atdGR.u_request_management_group) {
assign_group = atdGR.u_request_management_group.toString();
}
return assign_group;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2025 02:08 AM
Put some logs in it to see where it's failing. It would be easier to just put it in as a variable, right? Have them choose the group instead of letting them type it?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2025 02:11 AM
what debugging did you do?
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-16-2025 02:19 AM
I have tried making lots of changes to that script and it was't working, result was the same and goal wasn't acheived
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2025 03:43 AM
that's fine, but what are your findings when you added logs?
please share that.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader