The CreatorCon Call for Content is officially open! Get started here.

sys_trigger record creating by system user.

MamtaNegi
Tera Contributor

Hi All,

i want to run a job in batches for which i am using scheduled job script . This script is creating five sys_trigger entry which are 1hr time distance with required batch data.

 

But here i am getting issue ..when sys_trigger run it is calling a script include which adding record to multiple table after applying the transformation logic . I want these record to insert with specific user but as currently they are inserting as created by "system" user.

 

Although the user is set for "Run as' column of main scheduled job.

 

can anyone help me to get the desire result.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@MamtaNegi 

can you share the current script which you are using to create 5 trigger?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

M Iftikhar
Giga Sage

@MamtaNegi , You can configure the “Run as” field on the Scheduled Job form to control which user executes the job. However, only a single user can be selected there; and that’s also the recommended approach.

MIftikhar_0-1759830350226.png

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@MamtaNegi 

the Run As user simply controls the permissions for running the job.

It does not pass the user context for record creation inside scripts, and this is why you’re seeing "Created by: System" for inserted record

you will have to use custom logic to update the sys_created_by and sys_updated_by field with your user.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader