Usage of Display business rule with Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 04:18 AM
Hi,
Can Display business rule be used alone or it has to be used always with g_scratchpad variable in it and corresponding onLoad client script to call the scratchpad variable?
can you help here?
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 05:04 AM
Hi,
It depends really on what exactly your requirement is. You can definitely use a Display Business Rule alone as well. You need to use Scratchpad Variable which is a Global one only when you need to pass some Value from Server side to Client Side.
Basic idea of using Display BR is to read data from the Database and present it to the User when the form loads on which the Display BR has been written on.
For example, Consider two scenario as discussed below:
1) In this scenario I am not using any client side call, just displaying the Total Number of incidents present in the Related List on the Problem form using a Display BR as per the script mentioned below:
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", current.sys_id);
incident.query();
while (incident.next()) {
}
gs.addInfoMessage(incident.getRowCount());
})(current, previous);
2) Second scenario may be when you want to pass some values on to the client Side then you need to user global scratchpad variable in the Display BR and use it in client script as shown below:
Client Side:
So in the above screen shot you need to check for the scratchpad value as shown and can apply your logic as required as for example I have made the state field as Read Only if the User is a part of CAB Approval Group.
You may refer the below links also which may be useful:
Can anybody give realtime examples of Before, After, Async and Display Business Rules ? Please
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke