- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 07:46 AM
Hi Team,
Can someone help me with the best practices on fix scripts & Scheduled Jobs?
Regards,
Alok sahu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 08:06 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 08:05 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2019 05:31 AM
Thank you Robert 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 08:06 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 08:40 AM
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!