How to catch an OutOfMemoryError in servicenow?

Yu_G
Tera Contributor

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.

3件の返信3

Community Alums
適用対象外

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

 

Vishal Jaswal
Giga Sage

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!

Ankur Bawiskar
Tera Patron
Tera Patron

@Yu_G 

You cannot detect that.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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