Display Value from table

Hafsa1
Mega Sage

I have a table whose display_value=true set for location field.

I'm creating 1 catalog where for 1 reference variable I have to select country field from same table. Is it possible to populate country field value rather than location field? and how?

12 REPLIES 12

Hi Hafsa,

that's because your custom table display value is set to true for location field and not the country

if you want to show country in the reference variable then make display=true for country field or add the attributes to that variable

Regards
Ankur

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

Ali Shaikh1
Giga Expert

Please write down catalog client script:

 

function onChange(control, oldValue, newValue, isLoading) {

 

    var caller = g_form.getReference('country ', doAlert); // doAlert is our callback function

 

}

 

function doAlert(country ) { //reference is passed into callback as first arguments

 

  g_form.setValue('cmn_location',location);

 

}

 

  g_form.setValue('cmn_location',location);//Please change the variable name that you have exactly on your catalog form and table name.

 


Kindly mark the answer Correct and Helpful if this answers your question.

Ali.

 

Hafsa1
Mega Sage

Not helpful.

I have a custom table say "u_countryLocation_lookup" table where "location" field's display value=true. This location is used many other places hence, we can't change display_value=true.

Now in catalog item which I'm creating I have to query same table and get the country name(china_es, china_sw etc .) filled in variable. 

Hi

Just one question... Maybe you need to have a different approach..

What if your custom reference table would hold duplicate records in the "country" field, like

LocationCountrysys_id (of record in your custom table)
ADE1
BDE2
CUS3
DUS4

If you take this table as "Reference" to your Variable, you may end up having numerous duplicate records for country, which in fact you maybe do not want to...

Maybe you just need to created (or take) a different Reference table for selecting the Country?!?

Let me know if that answers your question, please.

BTW: I tried and did not find a way to make the UI act as you wrote above.

BR

Dirk

 

 

Hafsa1
Mega Sage

Hi Dirk

yes, that is the case. So, our custom table have many fields but below 4 are useful. Here for location field display=true

Now , in catalog we have created 2 variables. u_country and u_group and both are reference fields from same table "u_countryLocation_lookup".

If I select u_country it should show me "DE".

for u_group = "xyz"

But for both fields it is showing me "A" . That is my issue. I have to reference both fields from this table only. THis is not generic country/location issue but specific to this table.

 

LocationCountrysys_id (of record in your custom table)group
ADE1xyz
BDE2ABC
CUS3DEF
DUS4GHI