Get Previous Assigned To member

sp_18
Giga Contributor

Hi,

Here i have to get the previous assigned to member's name who reassigned his ticket to another i.e current assigned to member.

How can i get it?

Dear Insert First Name of Assigned To,

Insert Full Name of the person who re-assigned the ticket has re-assigned this support ticket to you for resolution.

Please find a summary below of the ticket you will need to action.

Thank You.

1 ACCEPTED SOLUTION

Hi Sheetal,



Here is your Final Code:



var gr = new GlideRecord('incident');


gr.addQuery('active', true);


//gr.addQuery('sys_id','2b15abf6db230300e77dd450cf961925'); // Just for testing one incident


gr.query();


if (gr.next()) {


var watch = current.watch_list;


var spl = watch.split(',');


gs.log(spl); //   the code is working till this line


for (var i = 0; i < spl.length; i++) {


var list = spl[i];


gs.log('List '+list);


var usr = new GlideRecord('sys_user');


usr.addQuery('sys_id',list);


usr.query();


if(usr.next())


{


gs.log('First Name '+usr.first_name);


gs.eventQueue('WatchlistAlert',current,usr.first_name,current.watch_list);


}



}



}



Thank you,
Ashutosh Munot



Please Hit Correct, Helpful or like,if you are satisfied with this response.


View solution in original post

15 REPLIES 15

Shishir Srivast
Mega Sage

you can check the old value in sys_history_line table based upon the incident sys_id


but sys ids differ in instances right?


Deepak Ingale1
Mega Sage

Hi Sheetal,



Looking at your requirement, it looks like you want to trigger notification when assigned_to changes



You can access the previous object in your business rule ( before , after )


You can condition your business rule like


current.assigned_to.changes() && !(gs.nil(current.assigned_to))     // if assigned to changes and assigned to is not emtry



var previousAssigendTo = previous.assigned_to


var currentAssigendTo = current.assigned_to



Based on this, you can get all the information required of the previous assigned to person.



Then you can fire an event and based on that event, you can trigger notification. Previous asisgned_to member information you can pass as one event parameter, current assigned_to information you can pass as second event parameter.



https://developer.servicenow.com/app.do#!/lp/new_to_servicenow/app_store_learnv2_automatingapps_ista...



Hope it helps




Other way, if you require for reportin, I would suggest to take a look at metric_definiton and metric_instance.



Metric instance


yes thank you for the response but this is to trigger notification by an event right?



But how to get the previous assigned to member name in email template?


as mentioned below -



Dear Insert First Name of Assigned To,---(current assigned to i.e ${assigned_to})



*(here i want to display previous assigned to member name)Insert Full Name of the person who re-assigned the ticket has re-assigned this support ticket to you for resolution.Please find a summary below of the ticket you will need to action.