please share business rules scenarios
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 10:41 PM
please share definition of business rules and scenarios of after,before, async and display for interview level.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:37 AM
Hi,
Business Rule: Business rules are the server side scripting, where the scripts are used to perform the database operation.
Before BR :- Before BR scripts execute before the data is being saved into the database.
Example:- In the user table, when new users are created with the first name and the last name, u can write before BR script to auto fill the email with the combination of first name and last name.
After BR :- After BR script execute after the data is being stored into the database.
Example:- When a problem is closed, close its related incident or problem task.
Async BR:- Async BR script runs asynchronously at the same time the data is being stored into the database in background.
Example:- When an incident is created, at the same time incident task(incident_task) must be created.
Display BR :- Display BR is used to display the server side data to the client whenever required with the use of g_scratchpad object.
Example:- onChange of caller, if you want to display the caller's email ID, you can make use of g_scratchpad Display BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 04:08 AM
Please go through following videos which covers all the scenarios for various business rules in ServiceNow.
https://www.youtube.com/watch?v=CPCRyT10zRM
Please Mark ✅ Correct/helpful, if applicable.
Thanks,
Srinivasulu Laggala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2022 12:00 AM
Hello,
Business Rule: Business rules is a server side script that runs when a record is inserted,updated,displayed or deleted or when table is queried.
Before BR :- Before BR scripts execute their logic before a database operations occur.
Example:- User should not able to resolve the incident if change record mentioned in change request is not closed.
After BR :- After BR script execute after the data is being stored into the database.
Example:- If all the catalog tasks request are closed completed then request item automatically closed.
Async BR:- Async BR script runs asynchronously at the same time the data is being stored into the database in background.
Example:- when Assignment group changes the update the tasks SLA group to current assignment group.
Display BR :- Display BR execute their logic when a form loads and a record is loaded from the database.the purpose of display BR is to populate an automatically instantiated object g_scratchpad.
Example:- display the incident number those are active and created from last 30days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2022 12:14 AM
Example of Before Business Rule
Scenario:
When user tried to close an incident, we need to check if there are any related child incidents, problems or changes associated to it, if yes the show error message and don’t allow user to close that incident. (Eg :- INC132434 is still open and you cannot close the current incident.)
Before/update
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id);
gr.addActiveQuery();
gr.query();
while(gr.next()) {
if(gr.state !=6 && gr.state != 7 && gr.state != 8){
var inclink = "<a href = \"https://" + gs.getProperty('instance_name') + ".service-now.com/nav_to.do?uri=incident.do?sys_id=" + gr.sys_id+ "\">" +gr.number+ "</a>";
gs.addErrorMessage('The incident '+ inclink + ' is a child incident. Please close the child incident before closing the incident.');
current.setAbortAction(true)
}
}