- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 06:24 PM
Hi Everyone,
I have this requirement wherein I need to automate the changing of a group name based on what group name is defined in a variable. I need this in a workflow activity. Below is the scenario:
Scenario 1: A user will submit a catalog item, and add the group name in a Reference field to be updated. Input the New Group Name in a single line text field. Once the form is submitted, it will automatically change the Group Name mentioned on the reference field with the new Group Name indicated in another field.
Is that possible? Can you guys helm ne on this? 🙂
Thank you in advance!
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 07:11 PM
Hi you can use below run script activity for the same
Script:
var getGroupName = current.variables.variablename; // reference type var of group
var newGroupName = current.variables.variablename; // new group name
var grp = new GlideRecord('sys_user_group');
grp.addQuery('sys_id',getGroupName );
grp.query();
if(grp.next())
{
grp.name = newGroupName ;
}
grp.update();
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 09:24 PM
you can get started from your side
But sample script might look like this in workflow run script
var groupSysId = current.variables.groupVariable; // name of variable which refers Group table
var newGroup = current.variables.groupName; // name of variable which holds new group name
var grp = new GlideRecord('sys_user_group');
if(grp.get(groupSysId)){
grp.name = newGroup;
grp.update();
}
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
‎08-08-2022 09:55 PM
The response marked as correct should have the update() line within the if
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
‎08-10-2022 04:21 AM
Thanks