User Criteria to EUC device
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 06:53 AM
Hi Community,
I've a requirement to make the user criteria for the one of the Quick links. Any suggestions how to create a new user criteria for the below condition? TIA.
Users with EUC device (u_type_of_device=EUC^owned_byISNOTEMPTY^install_statusIN2,6,9,1,3) = /alm_hardware_list.do?sysparm_query=u_type_of_device%3DEUC%5Eowned_byISNOTEMPTY%5Einstall_statusIN2%2C6%2C9%2C1%2C3&sysparm_view=
OR
Users with email addresses (emailISNOTEMPTY)= /sys_user_list.do?sysparm_query=emailISNOTEMPTY&sysparm_view=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 06:29 PM - edited 10-30-2023 07:06 PM
@Ankur Bawiskar - Can you please help me out here. I've written this below script but not sure how to check with user record and proceed further.(Owned by is having the User ref)
var gr = new GlideRecord('alm_hardware');
gr.addQuery('u_type_of_device=EUC^owned_byISNOTEMPTY^install_statusIN2,6,9,3,15');
gr.query();
if(gr.hasNext()){
answer=true;
}else{
answer=false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 08:40 PM
you are not querying the logged in user sysId
please incorporate the same
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-30-2023 09:33 PM - edited 10-30-2023 09:33 PM
@Ankur Bawiskar - Thanks for the reply.
I've queried with the loggedin user id, but still I can see the link in my profile though I dont have any hardware associated.
var userId = gs.getUserID();
var gr = new GlideRecord('alm_hardware');
gr.addQuery('u_type_of_device=EUC^owned_byISNOTEMPTY^install_statusIN2,6,9,3,15');
gr.addQuery('owned_by',userId);
gr.query();
if(gr.hasNext()){
answer=true;
}else{
answer=false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 10:03 PM
update as this and it should work if you have asset satisfying the condition
I have used addEncodedQuery()
var userId = user_id;
var gr = new GlideRecord('alm_hardware');
gr.addEncodedQuery('u_type_of_device=EUC^owned_byISNOTEMPTY^install_statusIN2,6,9,3,15');
gr.addQuery('owned_by',userId);
gr.setLimit(1);
gr.query();
answer = gr.hasNext();
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader