Calling script include in ACL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 10:57 PM
Hi All,
I have a requirement of create a customized table with two fields called User(abc) and CMDB CI Class(windows)
We need to write a function in script include that only user and class matching we should return true, Else it should look return false.
This script include again we are calling in ACL so that User from customized table only create CI, if user not present then we need to check else condition(check parent class is matching with our customized table class)
Script include name :WBC_INFY_CMDB_Framework();
CICreationAllowedForUser: function(ci){
var access1= this.checkLoggedUser(ci);
var cmdbclass= new GlideRecord('u_cmdb_users_classess');
cmdbclass.addEncodedQuery('u_userANYTHING^u_cmdb_class=Windows Server');
cmdbclass.setLimit(1);
cmdbclass.query();
if(cmdbclass.next()){
return true;
}
else {
var cmdbclass1= new GlideRecord('cmdb_ci');
cmdbclass1.addQuery('sys_class_name',cmdbclass.u_cmdb_class);//match
cmdbclass1.setLimit(1);
cmdbclass1.query();
if(cmdbclass1.next()){
return false;
}
ACL:
var cmdbACLHelper = new WBC_INFY_CMDB_Framework();
if (cmdbACLHelper.CICreationAllowedForUser(gs.getUserID(), current.sys_class_name)) {
answer=true;
}
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 02:53 AM
Hi,
what are you returning when record is not found?
you should return false
please share your latest script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 03:14 AM
HI
Yes we are returning false if the condition is not matched.
Below is the new script for ACL and Script include
ACL:
answer = false;
var cmdbACLHelper = new WBC_INFY_CMDB_Framework();
var result = cmdbACLHelper.CICreationAllowedForUser(current.u_tom_parent.sys_id);
if (result == true) {
answer = true;
Script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 03:20 AM
Hi,
it seems you are not having else for the if present at line number 226
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader