where to check post clone cleanup script run or not run

kushal_dangare
Tera Expert

Hi,

I have created one post clone cleanup script. I am not seeing it executed after the cloning.

Where can I check if its run or not run? Where to check the logs of any failure of this script?

1 ACCEPTED SOLUTION

simonpullen
ServiceNow Employee
ServiceNow Employee

Hello Kushal,

 

After a clone completes the post clone cleanup script is created as a scheduled job and runs to completion and then is removed.

 

The best way to audit and keep a track of if the script runs is to add log statements in the job so you can audit it quickly.

EG:

 

gs.log("Starting Script to remove email configuration");

< Code to process >

 

gs.log("Script to remove email configuration is completed");

 

You can also put some log statements in the code to give more details instead of just start and finish, you can add counts and checks to better debug the script if it didnt work as intended.

 

Regards,

 

Simon

View solution in original post

9 REPLIES 9

simonpullen
ServiceNow Employee
ServiceNow Employee

Hello Kushal,

 

After a clone completes the post clone cleanup script is created as a scheduled job and runs to completion and then is removed.

 

The best way to audit and keep a track of if the script runs is to add log statements in the job so you can audit it quickly.

EG:

 

gs.log("Starting Script to remove email configuration");

< Code to process >

 

gs.log("Script to remove email configuration is completed");

 

You can also put some log statements in the code to give more details instead of just start and finish, you can add counts and checks to better debug the script if it didnt work as intended.

 

Regards,

 

Simon

Which scope do these scripts run in? If I create a scoped clone cleanup script do they run in the scope of the scheduled job or the scope they were created in?

simonpullen
ServiceNow Employee
ServiceNow Employee

In the clone engine currently, it groups all of the clone cleanup scripts together and runs as one big job. This was to fix the issue with ordering as creating as seperate jobs we couldn't confirm the order.

 

At this current time the jobs are all running in global scope. A workaround for this is to have your code to create or to update a sys_trigger job in that scope so that it will run in that scope. That should work.

 

So either you have a job already there, or you create a fresh one and then it will run 

Thanks for the quick reply. One more follow up question. So this means allowing the global scope permissions to create sys_trigger records in the target scope? Isn't this is a bit of a security loop hole? So, global scope can run any arbitrary code in the HR scope? Doesn't this make delegated development a bit pointless?