How to check if a record is existing in a custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2022 11:25 PM
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
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 03:31 AM
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 04:24 AM
yes you can use advanced ref qualifier and filter that
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 05:07 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2022 06:04 AM
Hi,
u_group_owner, u_deputy and u_escalation_contact fields are on which table?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 08:24 AM
Hi
Thanks and Regards