The CreatorCon Call for Content is officially open! Get started here.

How to get previous assignment group name of the incident

VIKAS MISHRA
Tera Contributor

on Click of one UI action i need to check what was the previous assignment group of the incident so that i can re assign the incident to that group again when clicking on that UI action button.

Please tell me the code i can write in that UI action to achieve the same.

4 REPLIES 4

SatyakiBose
Mega Sage

Hello @VIKAS MISHRA 

Please refer to this community link here:

https://www.servicenow.com/community/platform-analytics-forum/identifying-the-previous-assignment-gr...

 

You just need to tweak it to work for incident table.

Could you please tell me the exact code what i can use

as i am using below one and its not working

current.assignment_group = previous.assignemnt_gorup;

Prince Arora
Tera Sage

@VIKAS MISHRA ,

There are many ways to achieve this functionality:
Way1: Though performing DB operations on sys_audit table is not recommended or not a best practice, but still let me explain you:
var gr = new GlideRecord('sys_audit');
gr.addQuery('tablename','incident');
gr.addQuery('fieldname','assignment_group');
gr.orderByDesc('sys_created_on');
gr.addQuery('documentkey',"ff4c21c4735123002728660c4cf6a758"); // pass the sys_id of incident as current.getUniqueValue()
gr.query();
if(gr.next()){
gs.info(gr.oldvalue);
}

Way2:
1) create a new field of type true/false as shown below

PRINCE_ARORA_0-1676483688042.png

2) Update that field in your UI action just for a trigger point as shown below:

PRINCE_ARORA_1-1676483744560.png

 

3) create a Business Rule to catch the trigger and update the assignment group:

PRINCE_ARORA_2-1676483794667.pngPRINCE_ARORA_3-1676483811416.png

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.