Reference users department from a list in a catalog request

Lars6
Tera Expert

We are updating one of our service catalog requests for approved software.  We added two lines one that the software is approved and a list what department is it approved for.  In the catalog request, we want it to only list the software if it is approved and if the user is in one of the departments on the list.  I know I can add the reference for if approved is approved but I can't figure out how to reference is a user's department is listed in the list.

 

Any help is much appreciated!

2 REPLIES 2

Deepak Shaerma
Kilo Sage

Hi @Lars6  Use Dot Walking for users department

add a reference variable that points to your software table.
For the first condition (software being approved), you can directly use a simple condition in the Reference Qualifier field of the variable setup. However, incorporating the check for the user’s department requires a more advanced setup.

1. Advanced Reference Qualifier: In your reference variable for selecting software, you’ll need to use a Dynamic or an Advanced reference qualifier.

2. Scripted Solution:
- Choose the Advanced qualifier type to input a script.

 

 

var encodedQuery = "active=true^u_approved=true";
encodedQuery += "^u_departments_approved_forLIKE" + gs.getUser().getDepartmentID();

// Set the encoded query as the qualifier
current.addEncodedQuery(encodedQuery);
answer = encodedQuery;

 

 


u_approved and u_departments_approved_for are example field names; replace them with your actual field names.
gs.getUser().getDepartmentID() fetches the current user’s department ID.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma



Lars6
Tera Expert

Thank you!  I think it is close.  I am trying to work through it.  There are two things I found when testing, in the answer for the returns Approved and not the name of the software (see image).  Also, I believe that the query is being allied to the request by and not the requested for.   

 

I am working on it, if I get it, I will post the results.

 

Thanks Again