- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 12:45 PM
I've written a business rule to prevent a user from inserting a record if priority is critical. Used setabortaction() for this. BUt it is also preventing user who perform updates and delete.
Using which method can i prevent only inserting to a record?
Business rule:
Table: incident
(function executeRule(current, previous /*null when async*/) {
if(!(gs.getUser().isMemberOf('HelpDesk') || gs.getUser().isMemberOf('Tier II Support SOI') || gs.getUser().isMemberOf('Tier II Support Passport') || gs.hasRole('admin'))){
current.setAbortAction('true');
gs.addErrorMessage("Users belonging to HelpDesk, Tier II Support SOI and Tier II Support Passport only can create a high priority ticket!");
}
})(current, previous);
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 12:52 PM
Check to make sure that the Insert checkbox is checked and the Update is NOT. Change the 'true' to true. It's a JavaScript keyword, not a string.
For readability I might suggest the following:
(function executeRule(current, previous /*null when async*/) {
var user = gs.getUser();
var isHelpDesk = user.isMemberOf('HelpDesk');
var isTier2SOI = user..isMemberOf('Tier II Support SOI');
var isTier2Passport = user.isMemberOf('Tier II Support Passport');
var isAdmin = gs.hasRole('admin');
if (!(isHelpDesk || isTier2SOI || !isTier2Passport || isAdmin)) {
current.setAbortAction(true);
gs.addErrorMessage("Users belonging to HelpDesk, Tier II Support SOI and Tier II Support Passport only can create a high priority ticket!");
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 12:46 PM
Only check the insert checkbox on this business rule. Uncheck all the other check boxes so that this business rule will only be triggered on insert.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 12:52 PM
Check to make sure that the Insert checkbox is checked and the Update is NOT. Change the 'true' to true. It's a JavaScript keyword, not a string.
For readability I might suggest the following:
(function executeRule(current, previous /*null when async*/) {
var user = gs.getUser();
var isHelpDesk = user.isMemberOf('HelpDesk');
var isTier2SOI = user..isMemberOf('Tier II Support SOI');
var isTier2Passport = user.isMemberOf('Tier II Support Passport');
var isAdmin = gs.hasRole('admin');
if (!(isHelpDesk || isTier2SOI || !isTier2Passport || isAdmin)) {
current.setAbortAction(true);
gs.addErrorMessage("Users belonging to HelpDesk, Tier II Support SOI and Tier II Support Passport only can create a high priority ticket!");
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 12:54 PM
Good catch chuck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 12:56 PM
Wow thanks so much. Silly mistake on my part