How to update comments in RITM with a particular user name

Ajai S Nair
Giga Guru

Hi All,

In one of my service catalog item, I have an approval and then based on that user is getting added to servicenow groups. I have provided script to update comments field along with user addition. Now when ever user is added to groups, the work notes are updated with the approver's name. Is there a way way to change this and provide some default user name for adding this comments?

Regards,

Ajai

1 ACCEPTED SOLUTION

Finally found a solution.


Instead of current.comments , I queried the sc_req_item table and updated comments field using GlideRecord.


Now comments are updated with impersonated user.


View solution in original post

5 REPLIES 5

raves12
Kilo Sage

Hi Ajai,



Please add below line before start of code in run script activity where you are updating comments:



gs.getSession().impersonate("a2826bf03710200044e0bfc8bcbe5ded");


current.comments = "Testing approver comments" ;



Replace sys_id with the "sys id" of the dummy user you want to update the comments.


Hi Ravi,



Sorry for the late reply.


the code which you have provided was helpful but even after using that comments were not updated with the impersonated user name.


I even tried with starting and ending impersonation with the code in below link:


Is there a way to Start and End impersonation using a script ?


Now for me task worknotes are updating correctly but RITM comments (additional comments) are still updated with last approver name.



Below is the code which is not working...



var myUser =gs.getSession().impersonate("sys_id of user");


current.comments = "Added "+userInfo.name+" to "+group.name;


gs.getSession().impersonate(myUser);



Any help is appreciated.


Finally found a solution.


Instead of current.comments , I queried the sc_req_item table and updated comments field using GlideRecord.


Now comments are updated with impersonated user.


HI All,



Is there any default business rule that updates additional comments in Request item when we update work notes in a catalog task ?


For me the work notes in task is updated with the impersonated user but later when the same gets updated in Request item it is updated with last approver name.


Any help is appreciated...