Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Advanced reference qualifier

vcicchirillo
Tera Contributor

Hello,

I would like to set an advanced reference qualifier that dynamically limits records on a reference Field 2 [u_field2] basing on what the user selects on another Field 1 [u_field1]. Field 1 and Field 2 are reference fields which reference the same table [A].
In detail, the table [A] has the following columns:

  • Name [u_name]
  • ID [u_ID]
  • Hierarchy [u_hierarchy]  -> It contains a series of concatenated IDs showing the hierarchy

When the user chooses a record on Field 1, I would like it possible to potentially select in Field 2 only the values ​​for which the ID of Field 1 is included in the Hierarchy (basically, the table [A] contains parents and related children, and the only way to relate child with parent is through the Hierarchy). 
In Dictionary Entry of Field 2, I tried to insert:

  • in Attributes -> ref_qual_elements=u_field1 
  • in Reference Qual -> javascript: 'u_field1.u_hierarchyCONTAINS' + current.u_field1.u_ID
     

Unfortunately, nothing happens: in Field 2, you see everything regardless of what you enter in Field 1. 
Surely, there is something wrong at the conceptual level or at the Javascript level; perhaps creating a script is required.

This is my first time writing in the forum, I hope the problem is clear and that someone can kindly help me.
Thank you in advance.

3 ACCEPTED SOLUTIONS

SanjivMeher
Mega Patron

Looks like you reference qualifier is wrong.

It should be 

Reference Qual -> javascript: 'u_hierarchyCONTAINS' + current.u_field1.u_ID


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

Abhijeet_Pawar
Tera Guru

Hello @vcicchirillo ,

remove u_field1 from your reference qualifier.

your reference qualifier should be 

javascript: 'u_hierarchyCONTAINS' + current.u_field1.u_ID 

Thanks.

View solution in original post

AniketC85155510
Kilo Patron

Hello @vcicchirillo ,

Please try with the below modified reference qualifier and let me know how it works for you.

 

javascript: 'u_hierarchyCONTAINS' + current.u_field1.u_ID;

 

AniketChavan_2-1705516717347.png

 

 

Please let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

View solution in original post

8 REPLIES 8

AniketC85155510
Kilo Patron

Hello @vcicchirillo ,

Please try with the below modified reference qualifier and let me know how it works for you.

 

javascript: 'u_hierarchyCONTAINS' + current.u_field1.u_ID;

 

AniketChavan_2-1705516717347.png

 

 

Please let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

Thank you very much, very helpful! 

Hello @vcicchirillo 

You're very welcome! I'm glad I could help. If you ever have more questions or need assistance in the future, feel free to reach out.

Have a great day!

Zuhaib
Tera Contributor
This video shows how to use an advanced reference qualfier on a list collector type variable on a catalog item in ServiceNow.