Hello Hemanth,

 

Your suggestion is much helpful we use the second one that displays as the guest instead of system, so please guide me . Where should we add the first script?

gs.event Queue("ptin",current,current.sys_id,gs.getUserID();
could you please navigate me in the instance. 

Hi @Kranthi Rohit ,

 

Do you know how the script action being called when attachment is added?? must be a Business Rule or flowdesigner, find that.

 

There you can find gs.eventQueue, add gs.getUserID() paramter and go to script action >>the add impersonation logic.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

hi Hemanth, 

I am new to this script action , I don't how the script actions are called in BR /Flow designer I checked every where I couldn't find .If you know how it called and where it is?. Please navigate me to there. That would be really a great help for me. thanks

Rajesh Chopade1
Mega Sage

Hi @Kranthi Rohit 

Try bellow script in your action :

// Get the current logged-in user
var currentUser = gs.getUserID();

// GlideRecord to update the active comments field (assuming the table is 'incident')
var gr = new GlideRecord('incident');
if (gr.get(current.sys_id)) {
    // Update the comments with the logged-in user's ID
    gr.comments = "File attached by " + gs.getUserName();  // Add your custom message here
    gr.setValue('sys_updated_by', gs.getUserName()); // Update sys_updated_by to the logged-in user
    gr.update(); // Update the record
}

Hi Rajesh, 

Thanks for your response,

It's  taking the  current user as system by default. its not showing the logged in user name.