10 Replies · Latest reply on Jan 13, 2018 9:44 PM by sheetalp

    Get Previous Assigned To member

      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.

       

       

        • Re: Get Previous Assigned To member
          Shishir Srivastava

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

          Thank you!

          Regards,
          Shishir Srivastava

          PS: Your feedback (Like, Helpful or Correct) helps community

          • Re: Get Previous Assigned To member
            Deepak Ingale

            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_istanbul_generating_even…

             

            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

            1 of 1 people found this helpful

            Note:Kindly mark reply as helpful/ correct if it has answered your question partially/completely

              • Re: Get Previous Assigned To member
                sheetalp

                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.

                  • Re: Get Previous Assigned To member
                    Deepak Ingale

                    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_automatingapps_istanbul_exercise…

                    1 of 1 people found this helpful

                    Note:Kindly mark reply as helpful/ correct if it has answered your question partially/completely

                      • Re: Get Previous Assigned To member
                        sheetalp

                        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);

                          • Re: Get Previous Assigned To member
                            ashutoshm1

                            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.

                            1 of 1 people found this helpful