User Criteria not working for Catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 10:11 PM
Hi All,
I have created a catalog item and would like to make it available which matches the below criteria.
If logged in user is Business Service owner, then the catalog item should be available for them.
I am trying with the below script. But it is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 10:35 PM - edited 06-18-2024 10:45 PM
Hello @mohanambalnanja ,
you have missed the parenthesis after businessServiceOwner.query.
Add parenthesis.Rest of the code is correct.
var userId = gs.getUserID();
var businessServiceOwner = new GlideRecord('cmdb_ci_service');
businessServiceOwner.addQuery('owned_by',userId);
businessServiceOwner.query;
answer = businessServiceOwner.hasNext();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 10:44 PM
Thanks for your response. Tried after adding the parenthesis. But still, it didn't give the expected result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 11:05 PM
function cmdb_ser(){
var businessServiceOwner = new GlideRecord('cmdb_ci_service');
businessServiceOwner.addQuery('owned_by', user_id);
businessServiceOwner.query();
return businessServiceOwner.next();
}
Can you check with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 11:17 PM
Hi @mohanambalnanja ,
var businessServiceOwner = new GlideRecord('cmdb_ci_service');
businessServiceOwner.addQuery('owned_by', user_id);
businessServiceOwner.query();
if (businessServiceOwner.next()) {
answer = true;
}
else{
answer = false;
}
Please Mark My Response as Correct/Helpful based on Impact
Mark this as Helpful / Accept the Solution if this helps.