Taking Cmn_loaction Reference for four fields Country, City, State, Address

VikramM1
Tera Contributor

Hi,

 

I have created four fields for all Country, City, State, Address and Taking Cmn_loaction Reference for all four fields.

 

When i select country: only country should be displayed.

When i select State: based on the country selected state should be displayed.

When i select City: Based on country and state selected. City should display.

 When i select Adress: Based on country and state and city selected. address should display.

 

But, all are showing only address.

 

How to acheive this in service now table form. Can someone help me on this?

13 REPLIES 13

Maddysunil
Kilo Sage

@VikramM1 

You'll need to use the "Dependent Reference Qualifiers" feature. This feature allows you to create cascading reference fields where the values in one field determine the available choices in another field.

Here's how you can set it up for your scenario:

  1. Create Fields: Create the fields for Country, State, City, and Address in your table.

  2. Create Reference Fields: Make sure each of these fields is a reference field, referencing the appropriate tables (e.g., Country referencing cmn_country, State referencing cmn_location, etc.).

  3. Configure Reference Qualifiers: For each dependent field (State, City, Address), you'll need to set up reference qualifiers based on the values selected in the preceding fields. This is done using a client script or business rule to dynamically update the reference qualifier whenever the parent field's value changes.

    For example, when configuring the State field, you would set a reference qualifier based on the selected Country. Similarly, for the City field, you would set a reference qualifier based on both the selected Country and State. And for the Address field, you would set a reference qualifier based on the selected Country, State, and City.

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

 

Thanks

If possible, can you please help me with client-side script to achieve this. 

Sai126
Tera Contributor

@VikramM1 ,

 

At the dictionary level, try adding Country as dependent field for State, State as dependent field for City and City as dependent field for Address.

 

If you dont see Dependent Field tab on the form, click on Advanced View related link.

 

Make sure you add Country as Parent for State likewise State as Parent for City and City as Parent for Address in cmn_location table

 

Please mark it as Correct if it solves your issue.

 

Best Regards

Deepak Shaerma
Kilo Sage

Hi @VikramM1 
Set Up Reference Qualifiers,  You can configure these either directly in the field configuration in the dictionary. 

Country Field: This field may not need a qualifier if all countries are to be displayed.

State Field: Use an advanced reference qualifier to display only states related to the selected country. You can filter based on the ‘Parent’ or related ‘Type’ field.

Example Qualifier Query: [Type] = State AND [Parent] = javascript:current.getValue('country')

City Field: Similar to the State field, but the filter will be more specific, showing only cities within the selected State.

Example Qualifier Query: [Type] = City AND [Parent] = javascript:current.getValue('state')

Address Field: This will filter to show addresses that are within the selected City.

Example Qualifier Query: [Type] = Address AND [Parent] = javascript:current.getValue('city')

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