How to check if a record is existing in a custom table.

Indira8
Kilo Sage

Hi All, 

We have a custom table where there are 3 reference fields dep, owner and escalation which refer to the user table. 
Requirement is that whenever logged in user tries to access the catalog item , if user is a part of any of these then certain variables should be visible otherwise no.
Could you help me with the code for querying the custom table and checking if the logged in user record is present in any of the fields.

Thank you 

15 REPLIES 15

@Ankur Bawiskar  , this is not working can we set a reference qualifier to the variable group_name based on the user logged in , so that the user will be displayed with only the groups in which he is owner or deputy or escalation contact

 

Thank you 

yes you can use advanced ref qualifier and filter that

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

@Ankur Bawiskar  Could you please help me with the reference qualifier condition based on the logged in user. 
The catalog item has 2 fields , logged in and user and group_name , based on the whether the logged in user is any one of Owner/deputy/escalation then only those names should be reflected in the variable group_name 

The following is the encoded query: 

var myUser = gs.getUser();
myGroups.addEncodedQuery('u_group_owner='+myUser+'^ORu_deputyLIKE'+myUser+'^ORu_escalation_contact=myUser');

 

Thank you 

Hi,

u_group_owner, u_deputy and u_escalation_contact fields are on which table?

Regards
Ankur

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

Hi @Ankur Bawiskar , the fields are on the custom table we created but they refer to the user table (sys_user)

 

Thanks and Regards