Business Rules :
- Business rules are the server side processing objects.
- Can be configured to trigger on create/read/update/delete operations into a table.
- Can be configured to execute before/after/async of any of the the above operations.
- Before rules are generally used for data enrichment, validation.
- After rules are generally used to configure notifications, perform upsert operations into a related table.
- Async rules are generally used for outbound integrations, heavy processing logic which could otherwise impact user experience.
- Display rules can be configured to pass on values from server side to client side scripts to eliminate the round trips.
- Query rules can be configured to add additional default conditions to all the query statements performed on a table.
Objects :
current : represents the current state of the record that is being processed. Available in before, after, query, display, async business rules.
previous : represents the previous state of the record that is being processed. Available in before, after business rules.
g_scratchpad : represents an object which can be loaded with key value pairs from server side to access at client side. Available in display business rules.
Avoid :
- current.update() in before business rules. Could lead to infinite loop of rule execution without proper conditions.
- outbound integration calls in before/after business rules. This impacts user experience.
- writing lengthy scripts in advanced business rules . Use script includes instead.
- Avoid global business rules. Use script includes where possible.
- Avoid circular updates among related tables. i.e Business rules on table A updating table B, and Business rules on table B, updating table A.
Stuck with ? :
Unique key violation detected by database : Could be because of current.update() in before business rules, or circular updates.
Workflow execution order : Workflows run before the insertion into table and after before business rules with order <= 1000. so, adjust the order if needed.
Empty journal fields : values of journal fields such as work_notes, comments are not available in an after business rules, use current.work_notes.getJournalEntry(1) instead.
Activities being duplicated : Could be because of current.update() in before business rules, or circular updates between related tables.
Here are the related articles on ServiceNow
No comments:
Post a Comment