i want records to be created with system username

rahulnagarajan
Kilo Contributor

Hi friends,

Have a basic question. how to create records with system as the user name. There are few places where i need to create records with some common names ... but dont want any specific login name on Public UI pages...

can you please help me with an example if possible! thanks a lot;!!!!

Best Regards

Rahul N

1 ACCEPTED SOLUTION

Hi Rahul,



If I understand your requirement, you need to override the created_by value with 'system' and other values like sys_created_on..etc to be kept as they come from the external system. Please correct me if I am wrong. This is not very ideal to do from the 'Audit' perspective. Technically you can achieve this using   as shown below.



var gr = new GlideRecord('incident');


gr.addQuery('number', 'INC1234567');


gr.query();


if(gr.next()){


    gr.sys_created_by = 'system';


    gr.sys_created_on = inputDate;


    gr.autoSysFields(false);


    gr.update();


}



Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin


View solution in original post

7 REPLIES 7

Anurag Tripathi
Mega Patron
Mega Patron

when you create a scheduled job, you can define as to what user it should run as and also timezone, there if you set the user as 'system' you will see those records created by 'system'


-Anurag

rahulnagarajan
Kilo Contributor

Thanks for your reply Anaurag. But how can it be always schedule job.. sometimes, it will come from user in UI pages..etc.



how do we solve those scenarios ?


Khanna Ji
Tera Guru

What do you want to achieve? who cares with what account used record is created? If it is an integration then you can use an integration account. I do not understand your issue here


my requirement is to keep the same username as system, data...etc which comes from the other system... integration username is different. cant be used.. any other ideas anybody?



any help?