logo

NJP

GlideRecord: If Record Exists (Imperative)

Developing Creative Business Solutions On ServiceNow on CodeCreative | A ServiceNow Blog · Aug 08, 2021 · article

Purpose: How to execute code conditionally if a matching record exists in ServiceNow Use: Use this script in a Server Script to test if a record exists before deciding how the code should continue. This allows handling error cases when a record doesn’t exist, creation of expected records, or an alternate handling path depending on whether the record exists or not. The call to setLimit is extremely important to maintaining the best performance by telling the database to stop searching after finding one matching record.

View original source

https://codecreative.io/notebook/gliderecord-patterns-if-record-exists/