Best Practice 1: Use system properties instead of hard-coded values.
When required values are hard-coded into the server-side scripts, changes to these values must be manually adjusted in every script where they appear. To save time and maintenance, create system properties with scripts using the values contained in those properties. When a system change is required, changes made to a single system property can be implemented system-wide.
Best Practice 2: Define and use a naming convention.
Define and use a naming convention that makes the property easy to manage. This allows users to filter custom properties from the hundreds in the system properties list.
To define a property:
Best Practice 3: Group properties into categories.
To create a category to group properties:
Best Practice 4: Create a Properties page to display properties.
The Properties page gives easy access to all of the properties in one place. To display properties, create a new module under the appropriate application menu.
Warning: System properties store configuration information that rarely or never changes. Each time you change or add a system property, the system flushes the cache to keep all nodes in the cluster in synch. This cache flush might cause temporary performance issues to the instance if done excessively. As an alternative to a system property to store configuration information that changes more than once or twice a month, you can use instead a custom table to store regularly changing configuration information.
Best Practice 5: Business Rules
The When field on the Business Rule form indicates whether the Business Rule script runs before or after the current object is saved to the database. The most commonly used Business Rules are before and after rules.
You can use an async Business Rule in place of an after-Business Rule. Async Business Rules are similar to after rules in that they run after the database commits a change. Unlike after rules, async rules run in the background simultaneously with other processes. Async Business Rules allow ServiceNow to return control to the user sooner but may take longer to update related objects.
Follow these guidelines to determine which value to choose for the When field.
Value | Use Case |
---|---|
display | Use to provide client-side scripts access to server-side data. |
before | Use to update information on the current object. For example, a Business Rule containing current.state=3; would set the State field on the current record to the state with a value of 3. |
after | Use to update information on related objects that need to be displayed immediately, such as GlideRecord queries. |
async | Use to update information on related objects that do not need to be displayed immediately, such as calculating metrics and SLAs. |