What is the Best Practice on fix scripts & Scheduled Jobs?

Alok21
Giga Expert

Hi Team,

Can someone help me with the best practices on fix scripts & Scheduled Jobs?

Regards,

Alok sahu

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Alok,

Both have their own advantages and limitations

 

 

Scheduled Jobs
1) always use setLimit() to test for few records whether update/delete happening or not; then remove this after confirmation

2) always try to use autoSysFields(false) for avoiding update to updated_by and updated_on fields

3) Always use try catch block so that even if error comes it will proceed and not stuck at that place

Fix Scripts

1) Always use try catch block so that even if error comes it will proceed and not stuck at that place

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

7 REPLIES 7

Uncle Rob
Kilo Patron

FIX SCRIPTS

- if you need to use them, use them.  They're a great tool when you know in DEV that you'll need data fixes deployed through Test & Prod.  Fix scritps are captured in update sets.

- If you just need an engine for scripting in ServiceNow, and don't intend to move the scripts between instances, its better to download Xplore by Whitespace Studios instead.

 

SCHEDULED JOBS

- Make sure your ServiceNow architecture is $%#!ing well documented, and make sure all Scheduled Jobs are painstakingly tracked.  It sucks showing up on a years' old instance and going "Hey what are all these scheduled jobs for" and everyone shrugs their shoulders all "I dunno, lets turn them off and see who screams".

- Be *certain* you need a scheduled job before using one.  There's a subtle difference between a delayed transaction, and a scheduled function.  Scheduled Jobs are for the latter.  You can get more mileage from business rules + gs.eventQueueScheduled() + script actions for the former.

Thank you Robert 🙂

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Alok,

Both have their own advantages and limitations

 

 

Scheduled Jobs
1) always use setLimit() to test for few records whether update/delete happening or not; then remove this after confirmation

2) always try to use autoSysFields(false) for avoiding update to updated_by and updated_on fields

3) Always use try catch block so that even if error comes it will proceed and not stuck at that place

Fix Scripts

1) Always use try catch block so that even if error comes it will proceed and not stuck at that place

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Good call on autoSysFields(false).  Also good to be aware of setWorkflow(false) if you don't want your record insert / updates to trigger business rules!