- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2016 05:50 AM
should ACL script return true explicitly to grant access?
will this below ACL return true if any of the condition satisify ?
current.isNewRecord() || current.request.opened_by == gs.getUserID() || current.request.requested_for == gs.getUserID() || gs.hasRole('itil')
Or should this be wrapped inside a function as below?
checkAccess();
function checkAccess() {
if (current.isNewRecord() || current.request.opened_by == gs.getUserID() || current.request.requested_for == gs.getUserID() || gs.hasRole('itil')){
return true;
}
else{
return false;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2016 06:15 AM
Both will work in same manner.
As per the wiki
The script must generate a true or false response in one of two ways:
- return an answer variable set to a value of true or false
- evaluate to true or false.
So since both of the values return to true. It will work in both conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2016 09:26 AM
Because of the usage of Global variables like current - the below link is for best practice for business rule but it applicable for all server side script -
"The recommended method for preventing such unexpected behavior is to always wrap your code in a function. This protects your variables from conflicting with system variables or global variables in other business rules that are not wrapped in a function."
Scripting in Business Rules - ServiceNow Wiki
Section 2
Not only server side script, its always advisable to wrap the variables in function even for client side script -
Client Script Best Practices - ServiceNow Wiki
Section 8
Mark if it is helpful