Change assignment group from current group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 07:58 AM
Hey Developers,
I have to change all Incidents which are currently assigned to "SD" to Network.
Condition : Requested for is Abel Tuter.
I tried to do it via Assignment rule but no luck.
I'm not getting any logic to use script.
Please suggest.
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 08:03 AM
Hi,
Do you want to update an existing record ? Then you have to create fix script Or want to update a record which will generate newly ? then you can use below client script
If you want to write logic for new records, follow below onSubmit() Client Script
function onSubmit() {
var caller = g_form.getValue('caller_id'); // abel tutor 62826bf03710200044e0bfc8bcbe5df1
var group = g_form.getValue('assignment_group'); //a797f9872f4f8110c8a259ab2799b6f6 sd-group
if((caller == '62826bf03710200044e0bfc8bcbe5df1') && (group == 'a797f9872f4f8110c8a259ab2799b6f6'))
{
g_form.setValue('assignment_group', '287ebd7da9fe198100f92cc8d1d2154e'); // network sys_id
}
}
Kindly mark correct and helpful if applicable

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 08:23 AM
Hi Naveen,
Navigate to System Definitions > Scripts - Background
Write below code :
var gr = new GlideRecord('incident');
gr.addQuery('assignment_group','sys id of SD group');
gr.addQuery('requested_for','sys id of abel tuter');
gr.query();
while(gr.next())
{
gr.assignment_group = "sys id of network group";
gr.update();
}
Mark as correct or helpful if it works for you.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2022 12:03 PM
To change group members, use the Add, Change, or Revoke ServiceNow Access forms. The 'Current Group Description' is displayed and may be updated in the 'New Group Description' field. If the new group description field is left blank the group description will remain unchanged. For more detail also see apkbik
https://community.servicenow.com/community?id=community_question&sys_id=bik