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-15-2022 11:35 AM
Example of before and after business rule:
scenario:
Create a new assignment group. Add 4 to 5 new members to the group.
When a new incident is created it should be auto-assigned to 1 member from the group.
If a member is already having an incident assigned to him, then next member should be selected.
Ticket assignment should work as – 1st member will be assigned 1st ticket, then 2nd member then 3rd and so on.
Solution: - Create 2 fields on user table – last task & last task date.
Create 1 field on group table – round robin group
Writ 2 business rules before insert/update :- User assigned group2
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group', current.assignment_group.u_round_robin_group);
grMember.orderBy('user.u_last_assigned_task_date');
grMember.query();
if(grMember.next()){
current.assigned_to = grMember.user;
}
After insert/update:- User assigned_user1
var grUser = current.assigned_to.getRefRecord();
grUser.u_last_assigned_task = current.sys_id;
grUser.u_last_assigned_task_date = new GlideDateTime();
grUser.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:49 AM
Need some more Business rules scenarios?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 03:57 AM
yes take it
after BR
When creating an incident table, when the user types an issue in the short description along with some dates mention it should be added as a choice in category drop-down and a date should be. Populated in “Issue Since” field (Example – Email not working since 2nd June. Email should be set as category and 2nd June should be set as issue since, format the date if required
solution
(function executeRule(current, previous /null when async/ ) {
var str = current.short_description;
var day, month, year, dateSplitted, aux;
gs.log('str'+str);
var result = str.match("[0-9]{2}([\-/ \.])[0-9]{2}[\-/ \.][0-9]{4}");
if (null != result) {
dateSplitted = result[0].split(result[1]);
day = dateSplitted[0];
month = dateSplitted[1];
year = dateSplitted[2];
}
var result = str.match("[0-9]{4}([\-/ \.])[0-9]{2}[\-/ \.][0-9]{2}");
if (null != result) {
dateSplitted = result[0].split(result[1]);
day = dateSplitted[2];
month = dateSplitted[1];
year = dateSplitted[0];
}
if (month > 12) {
aux = day;
day = month;
month = aux;
}
var issuedate = year + "-" + month + "-" + day;
current.u_issue_since = issuedate;
var cate = str.split(issuedate)[0];
current.category = cate;
gs.log('car value'+cate);
gs.log('issue since value'+issuedate);
current.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 04:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 11:13 PM