How to catch an OutOfMemoryError in servicenow?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
03-17-2025 05:34 PM
Hi everyone,
Is it possible to do Java try-catch when OutOfMemoryError occurs? How to do that?
If u have any ideas please feel free to comment.
Thank you so much.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
03-17-2025 09:11 PM
Hi @Yu_G ,
I doubt on try-catch , if that's possible.
However, to troubleshoot , you can use these links :
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0623271
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
03-17-2025 09:15 PM - 編集済み 03-17-2025 10:04 PM
Hello @Yu_G
try catch is possible in javascript which ServiceNow leverages for development and configuration however if your instance ever throws such exception, then the ServiceNow support team will be able to see such exceptions at their end instead of ServiceNow developers/administrators.
Here is a sample ServiceNow background script which will definitely throw an error as
try {
gs.info("Script execution started.");
var grInc = new GlideRecord('incident');
grInc.query();
while (grInc.next()) {
// Intentionally simulating a potential error (e.g. accessing an undefined property)
if (!grInc.number) {
throw new Error("Incident number is missing for sys_id: " + grInc.sys_id);
}
gs.info("Processing Incident: " + grInc.number);
}
gs.info("Script execution completed successfully.");
} catch (e) {
gs.error("Error occurred: " + e.message);
}
Hope it helps!
Hope that helps!
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
03-17-2025 09:32 PM
You cannot detect that.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader