Help with advanced reference qualifier

Abhijit Das7
Tera Expert

Hi All , 

 

I am new to reference qualifier. I have a task to set reference field look up in such a way that , it should sort look up according to whatever is populated in that reference field .

 

For example: 

1. I have one reference field on cases and it is populated with value New_tenant.

 

ft1.PNG

2. Now once I open look up it should display only those record which start with New, like this.

 

ft2.PNG

 

In order to achieve this I want to use Advanced reference qualifier of that field and set look up in such manner. Please help suggesting something.

 

cc: @Ankur Bawiskar @kamlesh kjmar 

 

Thanks in advance.

1 ACCEPTED SOLUTION

kamlesh kjmar
Mega Sage
Mega Sage

Hi @Abhijit Das7 ,

 

For your use-case, first you need to decide one logic for the filter condition. For an example in the above screen shot you want your filter to search for record that starts with New so for that logic becomes :

 

Split the selected value by under score symbol and then use the first split to search, but this logic won't work if there a name with no '_' symbol in it.

 

You can think of another logic where you can split the selected value by space and use the first split as a search word but this will not work for the names which are separated by '_'

 

One last logic you can come-up with is take a substring of the selected name, say select first 3 characters of the selected name and use it for filtering.  This you can consider. I am showing you how you can achieve your functionality with this logic:

 

1. I am taking an example of a custom field in incident table Device Incident which is referencing to incident table.

 

kamleshkjmar_0-1675319138839.png

Now in this I am putting the logic that if you select any incident in this and then if you click on the search icon of the field it will filter and show only those incidents whose Number starts with first seven character of the incident already choosen. In the above example it will show incidents whose number starts with INC0019

 

kamleshkjmar_1-1675319433869.png

 

Below is the logic I have used in my reference qualifier of Device Incident field

 

kamleshkjmar_2-1675319597877.png

javascript:current.getValue("u_device_incident") != "" ? "numberLIKE"+(current.getDisplayValue("u_device_incident")).substr(0,7):"numberISNOTEMPTY"

 

Change your filter logic as per your requirement, but process of doing this will remain the same.

 

I hope this helps.

 

If this solution helps you then please hit the Helpful button and if this solves your issue then hit Accept button as well.

 

Regards,

Kamlesh

View solution in original post

20 REPLIES 20

Hi @Ankur Bawiskar 

 

There is one reference field called CareAR Instruct Experience on cases table which is refernced to a table call Instruct Experience.

 

This Instruct Experience table has varioue fields like Experience Name , Experience ID , etc. But Experience Name ( Display = true). 

 

So CareAR Instruct Experience field will be referneced to this table and when I populate this field first time then it should show all the records in look up . But if I want to change the value of reference field second time then look up should display only those records whose experience name should start with same letter as of previous value . 

 

 For eg: If I select " Agent " first time from the look up of refernece field.

then next time open look up it should show all records which start with letter A.

@Abhijit Das7 

how will system know you did lookup for 1st time or 2nd time? It won't

This doesn't seem to be a valid business requirement

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

 

Please allow me to explain what do I mean by first time and second time.

1. First time means when nothing is populated in that reference field then look up should show all records. 

for eg: if reference field is empty then look up should show all records .

 

2. Second time means when any value is already populated in that reference field then look up should show only those records which start with same letter as already populated field .

for eg : if "help" is populated in that reference field then it should show only those record which start with "h". 

 

Thanks

@Abhijit Das7 

will user save the form after setting value for the 1st time?

also are you tracking how many times the field got updated? without this how will you know whether it's first time or 2nd time or 3rd time?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar @kamlesh kjmar 

 

Yes user will save the form after setting value for the first time . And user will save forms all times after selecting value.

 

And I want to set in a way that . if field is empty then it should show all records otherwise if field is populated then look up should show records based on already existing value. It should not depend on first time , second time . third time etc . Rather it should be based on empty or filled.

 

Thanks.