- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2019 06:10 AM
Can You please explain What is TRY CATCH
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2019 06:14 AM
Hi Naveen,
basically try catch block is used to handle exceptions and is good practice
Example: consider an example where you need to run a background script which would update 1000 records on table based on some condition; such as update field and do concatenation etc
if you don't use try catch block and if the update fails because of some reason because of invalid character etc the subsequent records won't be updated and code would break.
if you use try catch block then it would log the exception and proceed to the next records; in this way only that record won't get updated and all others for which exception is not thrown would get updated
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
12-05-2019 06:14 AM
Hi Naveen,
check the explaination provided to the below thread, it will be very useful for understanding the try/catch concept:
If I have answered your question, please mark my response as correct and/or helpful.
Thank you very much
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2019 06:14 AM
Hi Naveen,
basically try catch block is used to handle exceptions and is good practice
Example: consider an example where you need to run a background script which would update 1000 records on table based on some condition; such as update field and do concatenation etc
if you don't use try catch block and if the update fails because of some reason because of invalid character etc the subsequent records won't be updated and code would break.
if you use try catch block then it would log the exception and proceed to the next records; in this way only that record won't get updated and all others for which exception is not thrown would get updated
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