Tricky Reference Qualifier on Catalog Item Variable

jmiskey
Kilo Sage

We have three Custom Tables for a project that look like this:

 

Project Table:

jmiskey_0-1738686850346.png

 

Enviornment Table:

jmiskey_1-1738686881770.png

 

Role Table:

jmiskey_2-1738686912050.png

So, on the Catalog Item, they need to fill out three Reference fields (variables) based on these tables:

- Project selection

- Environment selection

- Role selection

 

The Role selection field has a Reference Qualifier, to only show active records where the Project field matches the Project selection and the Environment field matches the Environment selection.  We have this working the way that we want.  Here is the tricky part, they would like to add a Reference Qualifier to filter the Environment selection based on the other two tables.

 

For example, if they chose Project Name "AAA", we can look at the Role table, and see that there are 3 active records that have a value of "AAA" for Project.  These represent two environments: PRD (for two of the Roles) and TST.  So since PRD and TST are the only Environments for active records in the Role table that have a value of "AAA" for the Project, the Environments selection should be filtered to only allow them to choose from PRD and TST.

 

How would we write the Reference Qualifier (probably needing a Script Include) to do that? 

By the way, the Project and Environment fields in the Role table are References to the other tables.

(Note: I thought originally of adding a check box for each Project type to the Environment table, and having them maintain that, but that isn't feasible, as new Projects may be added in the future, and we do not want to just keep adding new check box fields every time a new Project is added!).

 

Thanks

 

 

 

6 REPLIES 6

I had tried many different ways, and none were working yesterday.  So I posted another question on this particular feature, trying to weed out the duplicates, and finally got a response that works here: https://www.servicenow.com/community/developer-forum/eliminating-duplicates-records-from-an-array-in...

 

Thanks for your efforts!

Also note, I did try your latest code.  Even if I fix the errors in the code you just posted (missing curly brackets) and try running it, it did not work.  The duplicates are still there.  But I have a working solution now, so no need to worry about it anymore.