Saurabh S
Giga Guru
Giga Guru

Dear Community members,

 

Sharing a few coding best practices recommended by ServiceNow. This is part 1 and please stay tuned for further updates.

1. Do not configure the password in your code. Use Basic Profile or system property to store the password.

2. Remove unwanted log & Info message.

3. Use JSUtil to check Null or undefined values. It is optimized compared to using null/undefined separately.

4. Synchronous(getXMLWait()) call present in GlideAjax, should be converted to asynchronous call(getXML(function name)). Using getXMLWait impacts performance.

5. Use UI Policy to make field mandatory, visible & Readonly instead of client script.

6. Use JSON.stringify(myObject) to change an object to a string instead of using new JSON().encode(myObject).

7. Avoid Using GlideRecord | GlideAggregate |GlideRecordSecure in ACL as it impacts performance.

8. Avoid using Global Business rules as it will execute in all the tables and will impact performance. Use Script Include instead.

9. Do not use current.update() and current.insert() in Business Rule. Current.update() is unnecessary in a business rule that executes before the database activity. Use of this function causes double updates and impacts performance.

10. Avoid using g_form.getReference() as it impacts performance. Usage of GlideAjax or getReference with Callback function is suggested.

Please Like or Mark Helpful if this article helped you in any way in your ServiceNow dev/admin/architect journey. Thanks.

Version history
Last update:
‎02-24-2025 12:49 PM
Updated by:
Contributors