Advanced user criteria for Business portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2025 09:40 AM
I need to create a user criteria that meets the following criteria: The Contract table is ast_contract, the Contact table is customer_contact, and the Account table is customer_account. This should be an advanced user criteria with a script to check the current contact in the portal, considering the contacts in the Contact tab of the customer_account table, query all ACTIVE contracts for the account they are part of, and then query, depending on whether they are AMS criteria, the sys_id of the contract model found in the sn_b2b_portal.glide.sc.portal.ams_contract_models property. If the glidequery contains next, that is, there is at least one record, return true; otherwise, return false.
I created this code, but it's not working. Could someone please help me?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2025 10:02 AM
Hi @mariasilva ,
Can you try this
var account = new GlideRecord('customer_account');
account.addQuery('contact', user_id); //user_id to get logged in user sys_id
account.query();
if (account.next()) {
var contract = new GlideRecord('ast_contract');
contract.addQuery('account', account.sys_id);
contract.addActiveQuery();
contract.query() //to get initiate the query to retrive records
var maintModels = gs.getProperty('sn_b2b_portal.glide.sc.portal.maintenance_contract_models').split(',');
contract.addQuery('contract_model', 'IN', maintModels);
contract.query();
return contract.hasNext();
}
return false;
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025