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

Hi Sheetal,



Yes, it is to trigger an event based notification.



In your notification, you can use email scripts to access the event parameters which you can use in your email template.


Mail script has access to event parameters, you can access both the event parameters and construct your notification accordingly.



Scripting for email notifications


https://developer.servicenow.com/app.do#!/lp/servicenow_administrator/app_store_learnv2_automatingap...


hmm thanks got your point



one more i have a code , can you please check and tell me where is the error?


(function executeRule(current, previous /*null when async*/) {




var gr = new GlideRecord('incident');


gs.addInfoMessage('hi');


gr.addQuery('active', true);


gs.addInfoMessage('1');


gr.query();




if (gr.next()) {


gs.addInfoMessage('2');


var watch = current.watch_list;


gs.addInfoMessage('A'); //   the code is working till this line


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


      gs.addInfoMessage('3');


var list = watch[i];




gs.eventQueue('Watchlist Alert',current,list.first_name.getDisplayValue(),current.watch_list);


        gs.addInfoMessage('3');


          }


                              }


})(current, previous);


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.


thank you so much its working but how to print parm1 in email template?


HI Sheetal,



Use ${event.parm1}



It will be good if you mark it as correct.



Thank you,


Ashutosh Munot