How to Display City Value from Location Table (Reference Field)

yana7
Tera Contributor

I have a Case with fields "Location" and "City," both referencing the Location table. I need the "City" field to display the City value from the Location table without changing the field type.

yana7_0-1720413721254.png

 

2 REPLIES 2

Rupanjani
Giga Guru

Hi @yana7,

 

We can directly get the city displayed along with location, without creating a new field.

As location is a reference field. We can get the 'City' field from location record to the Case Record.

 

  • Open any case record and click on 'Additional actions' icon.
  • Click Configure --> Form Layout.
  • Select Location and click on Expand selected reference field icon.

     

    Rupanjani_1-1720416645829.png
  • Select the City field from 'Available' list and move it the 'Selected' list. Click 'Save'. 


Mark the response correct and helpful if the answer assisted your question.

Vrushali  Kolte
Mega Sage

Hello @yana7 ,

 

To achieve this please follow below steps :

 

1. Got to the table definition, in the Display Value column make sure no field is set to True i.e. every field available on form should have Display value to False.

2. Create onChange client script for both city and location field respectively and add the code as below.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
    var ref = g_form.getReference('u_city'); //replace the backend name as per your use case for location and city
	g_form.setValue('u_city','',ref.city);
   
}

 

 

VrushaliKolte_3-1720422843646.pngVrushaliKolte_4-1720422872754.png

 



 

VrushaliKolte_2-1720422796280.png

 

I have tried this in my PDI and it is working for me.

 

If my answer solves your issue, please mark it as Accepted ✔️ and Helpful 👍based on the impact.