Capture Lookup Value in Hidden Value

Hello,

We want to use the community name to look up Latitude/Longitude coordinates.

Lookup table: WMAT_GPS
Column in lookup table to match: Comm_ID
Value in form that links to lookup table: y_community_reside
Columns in lookup table to save: Latitude, Longitude

Below is my attempt at the code for the hidden value question, but I’m getting an error message. Can you help me figure out where I went wrong?

instance(‘WMAT_GPS’)/Latitude[index = #form/index]/#form/y_community/y_community_reside
instance(‘WMAT_GPS’)/Longitude[index = #form/index]/#form/y_community/y_community_reside

Hi Alexandra,

Referencing lookup tables in Hidden Values is certainly tricky! The confluence page on displaying a random question from a lookup table has some generally useful tips.

In your case, you likely want something like this (assuming #form/index corresponds to your Comm_ID:
instance('WMAT_GPS')/WMAT_GPS_list/WMAT_GPS[Comm_ID = #form/y_community/y_community_reside]/Latitude
instance('WMAT_GPS')/WMAT_GPS_list/WMAT_GPS[Comm_ID = #form/y_community/y_community_reside]/Longitude

Note that the comparison within the brackets serves as a filter on the lookup table, limiting the results to only those rows in WMAT_GPS whose Comm_ID corresponds to y_community_reside. Once filtered, you then add the reference to the particular column that you want to access.

This is quite a bit more technical than the Confluence documentation, but you can read more about XPath evaluation here if you’re curious!