- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 07:11 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 08:46 PM
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'
});
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 07:18 PM
As this is a Client Callable ScriptInclude, there might be a ACL created by default for security purposes.
If you want this to be callable to all users, you should remove that ACL.
Navigat to ACLs and check for ACL of type Client Callable ScriptInclude and name of the ACL as name of your Script Include (getassettag in your case). De activate this ACL (you need to have security_admin role at you should have elevated your access) and save.
Logout from all your sessions and clear the browser cache and then log back in and try calling your script include.
Please mark my answer helpful and accept as solution 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 07:52 PM
Hello @AnveshKumar M
Thank you for your suggestion.
I deactivate "client_callable_script_include type ACL and clear out the browser cache, but that did not work. I might have missed a step along the way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 08:01 PM
As per the screen shot, I see you have de activated a "*" ACL, the ACL you need to deactivate is the one with the name getassettag.
And as mentioned by @Vishal Birajdar you should also check read access to the users to alm_asset table.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 07:50 PM
Apart from what is mentioned by @AnveshKumar M , also put some logs in script include to check if it is triggered for non-itil users.
If you are getting logs but it's not returning any results then it might be possibility that non-itil users are missing "Read" level
access on "alm_asset" table.
So, you need to provide them Read level ACL.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates