- 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 08:07 PM
I'm still have a long way to get better at writing script. Where and what do I need to add login logic?
Here is the script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 08:17 PM
Follow the below steps :
Step 1: Put some logs highlighted in bold
Step 7: if you are getting this log for non-itil users then users have access to script include.
This means users are missing Read level ACL on alm_asset table.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 07:54 PM
Hi @Lisa Goldman ,
Below article may helpful, have a looks
Please mark my answer helpful and accept as solution
Thanks,
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 08:02 PM
I have reviewed the suggestion link, but it did not help much. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 08:11 PM
Hi @Lisa Goldman ,
Have you tried to generate logs in your script include ? are you able to call script include with end user role ? try to print logs to know till which line your code working and which is not working.
And also try to query Asset record which is assigned to end user and see the out put,
Please mark my answer helpful and accept as solution
Thanks,
Swamy