How to change 'created by' as 'System'? Please help

Haceena Shaik
Tera Expert

Hi Team,

 

we have  catalog item to create/insert new user in sys_user table using run script like below. If the user gets created by catalog form, the created by field needs to be changed to "System".

 

 

Run script:
var usr = new GlideRecord('sys_user);
usr.initialize();
usr.first_name = current.variables.v_first_name;
usr.last_name = current.variables.v_last_name;
usr.insert();
//for created by to 'system'
var pr=new GlideRecord('sys_user');
pr.addEncodedQuery('sys_created_by!=AD Integration User^ORsys_created_byISEMPTY^ORsys_created_byISNOTEMPTY^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()sys_created_by!=AD Integration User^ORsys_created_byISEMPTY^ORsys_created_byISNOTEMPTY^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
pr.query();
if(pr.next()){
pr.sys_created_by='System ';
pr.update();
}

 

7 REPLIES 7

ABHAY_M
Tera Guru

What is the issue your getting?
any error message?

Hi @ABHAY_M ,

Thanks for Quick response..

 

With the script it is not updating 'created_by' as 'System'.

 

 

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

If the script executes in the system session then this field will automatically have system. Otherwise you cannot change it afterwards.

 

Where is this script running?

-Anurag

-Anurag

Hi,

 

Script is in workflow. Once the catalog item is submitted, it is showing 'created by'  in user record as catalog item submitted user. I want it to 'system'. It's not working..