Issue with attachment comments updated by system not by the logged in user

Kranthi Rohit
Tera Contributor

On change form when we used to attached the file in actives comments are updated by system it is not showing the logged in user. Those comments are coming from script actions. is there any way to update the name by logged in user instead of system ? All inputs are much appreciated.

7 REPLIES 7

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.