Calling script include in ACL

Rajamouly
Tera Expert

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;
}

7 REPLIES 7

Hi,

what are you returning when record is not found?

you should return false

please share your latest script

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

HI @Ankur Bawiskar 

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:

find_real_file.png

Hi,

it seems you are not having else for the if present at line number 226

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader