How to display only records whose Contract field matches the logged-in user

Y_O
Mega Expert

Hi Community,

I'm having a hard time setting variable in the catalog of the customer service portal.
I'm trying to display only the servers that match the Contract associated with the logged-in user.

Below are the current variable settings.

    Application: Customer Service
    Type: List Collector
    Type Specifications
        List table: Server [cmdb_ci_server]
        Reference qualifier: (Where I am asking)

If it is a company, it could be realized by describing the following in the Reference qualifier, but it seems that the Contract cannot be made so easily.

javascript:"company=" + gs.getUser().getCompanyID();

I have little knowledge of scripts and have just started developing ServiceNow.
Please give me an approach to this challenge.

Thanks in advance.

7 REPLIES 7

Hi,

As per your screenshots, I can see that u_contacts is a LIST type field, so the query needs to be changed here.

contract.addQuery('u_contacts', gs.getUserID()); // change this line to below.

contract.addEncodedQuery('u_contactsIN'+gs.getUserID());

 

Please mark this as correct and helpful if it resolved the query or lead you in right direction.

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hello,

Thank you for your quick reaction. Thanks to you, we are working towards a solution, but there still seems to be something wrong. I will investigate a little more.

I'll update here as I progress.

Thanks a lot,

Sure, If the query is answered then you can mark it as correct so that it can be moved from unanswered queue and others can get benefited from the same.

If you need further help on this, apart from the above query, then I would suggest you to create another question for that. 

Happy learning 🙂

 

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)