- 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 06:31 PM
Hello,
What have you tried thus far?
You haven't really showed us anything you're doing on your side?
As far as how to approach this, you can use a Run Script activity in the workflow, then use GlideRecord to query the group table filtering for the sys_id that matches the current.variables.group_reference_variable and then once found, set the group name using the variable that holds the value, then update the record.
Example of GlideRecord here: https://developer.servicenow.com/dev.do#!/reference/api/paris/server/no-namespace/c_GlideRecordScope...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 08:03 PM
Hi Allen,
Thanks for this. I'll try first to create a catalog item then will let how it goes.
Regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 07:26 AM
Hello,
I'm glad you found a correct answer that works for you.
As you know, it would be ideal to have seen you approach this yourself and then let us know if you have any additional questions (as I detailed everything above and included a link documentation) and it's not clear if you've actually used/tried the script that was provided?
With that said, if your issue has been resolved, that's great!
Take care!
-Allen
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- 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