Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Script actions run as system

Prasad63
Kilo Explorer

Hi All,

I have created a script action when it runs all the updates which run by script action is showing as "System".

Is there any way to show particular user name?

Thanks in advance,

4 REPLIES 4

Dubz
Mega Sage

If you're adding comments you can set the author of the comment by using setJournalEntry eg:

gr.comments.setJournalEntry('this is a comment', 'Users Name');

For other things, i've had some success with using GlideImpersonate, basically impersonating a session with a different user before making the update, worth a try:

var impUser = new GlideImpersonate();
impUser.impersonate('sys_id of user');
gr.insert()/gr.update()

Hi,

Thanks for information.

If i add code like below it will work.

rec.sys_updated_by = "CMD";

 

Thanks,

 

 

Try it out and see! I'm not going to test it for you 🙂

Prasad63
Kilo Explorer

Hi,

Thanks for information.

If i add code like below it will work? Please confirm.

rec.sys_updated_by = "CMD";

 

Thanks,