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

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


thanks antin!!!!! exactly what i was asking help. please explain the audit issues??



Best Regards


Rahul N


Hi Antin,

I have done this way earlier but the ask is if you go for audit logs apart from sys_created_by all other places it shows as Original user name due to whom the BR was triggered. 

Is there a way to show the BR is executed by System.

 

Regards,
Imran