Script Include is not trigger for non-itil users

Lisa Goldman
Kilo Sage

Hello,

I have a script includes that query 'alm_asset' table to retrieve asset tag. It's working fine as an admin or ITIL user, but when I impersonate an end user with no roles, no data is returned."

 

Could someone please help?  Here is the script include for your review.  Thank you

 

LisaGoldman_0-1696385338955.png

 

 

 

1 ACCEPTED SOLUTION

@Lisa Goldman 

it should be simply this

var getAssetTag = Class.create();
getAssetTag.prototype = Object.extendsObject(AbstractAjaxProcessor, {

 

isPublic:function(){
return true;
},

getDetails: function() {
var arr = [];
var sysId = this.getParameter('sysparm_sysId');
var gr = new GlideRecord('alm_asset');
gr.addQuery('assigned_to', sysId);
gr.addQuery('asset_tag', '!=', '');
gr.query();
while (gr.next()) {
arr.push(gr.asset_tag.toString());
}
if (arr.length >= 2)
return arr.toString();
// else
// return '';
},

type: 'getAssetTag'
});
Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

20 REPLIES 20

@Lisa Goldman 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar 

Your suggested code is working out fantastic.  Thank you and everyone for your help; it greatly improved my coding skills. I genuinely appreciate it.

@Ankur Bawiskar 

I ran into the same issue in Catalog client script.  Can I use isPublic function in the following code;

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//Type appropriate comment here, and begin script below
var mgr = g_form.getReference('who_is_this_request_for', setFields);

}

function setFields(mgr) {
g_form.setValue('current_manager', mgr.manager);

}

@Lisa Goldman 

isPublic is only for script include.

you need to check if the end user has read access to the table being referred by the variable "who_is_this_request_for"

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

Hi Ankur,

I have the same issue, I have deleted the acl and used the below isPublic function in script include. But still its not working for itil users.

isPublic: function() {

return true;

},