User Criteria to EUC device

Janu sree
Tera Guru

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=

11 REPLIES 11

Janu sree
Tera Guru

@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;
}

 

@Janu sree 

you are not querying the logged in user sysId

please incorporate the same

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

@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;
}

@Janu sree 

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();

 

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