Select to view content in your preferred language

is it possible to get a value from a table based on an entered value in the SAME form?

967
3
Jump to solution
07-27-2023 08:51 AM
WilsonLee
Regular Contributor

Hello all,

I have a Field Maps form and have 2 fields. 

Field 1: Tree Species Code (SPECIESCOD)

Field 2: Botanical Name (BOTANICAL)

in a same form, after the user enter Field 1 (Species Code), can Field 2 (Botanical name) auto-populate based on a table in the same webmap?

 

SPC_CODE
BOTANICAL
ABBRAbies bracteata
ABCIAbies cilicica
ABCOAbies concolor
ABGRAbies grandis
ABPIAbies pinsapo

 

Field 1: user enter ABBR

Field 2: will go to the table and look up ABBR , then the form will auto-populate "Abies bracteata"

(the table is a standalone table in the web map, and it's not join or relate w/ the layer with the form in Field Maps. I saw many sample with using relate table in arcade, how about a standalone table, is it possible? any tips or sample on setting it up in Arcade?

i have this in Arcade, but it gave me an error:

var SpeciesCode = $feature.SPECIESCOD
var table = FeatureSetByName($map, "TI2_DEV - SP_CODE_LOOKUP")
var botanicalName
var filteredTable = Filter(table, "SPECIESCOD = @SPC_CODE")
var result = First(filteredTable)
if (result) {
  botanicalName = result.BOTANICAL
}
return botanicalName

thanks so much!!

W

0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Notable Contributor

This seems to be working.  Stand alone table, but, added to the map.

 

var SpeciesCode = $feature.Species
var table = FeatureSetByName($map, "TreeTable",['SPC_CODE', 'BOTANICAL'])
var filteredTable = Filter(table, "SPC_CODE = @SpeciesCode")
var result = First(filteredTable)
if(!IsEmpty(result)){
  return result.BOTANICAL
}

 

May have to adjust the field names.

R_

View solution in original post

3 Replies
RhettZufelt
MVP Notable Contributor

This seems to be working.  Stand alone table, but, added to the map.

 

var SpeciesCode = $feature.Species
var table = FeatureSetByName($map, "TreeTable",['SPC_CODE', 'BOTANICAL'])
var filteredTable = Filter(table, "SPC_CODE = @SpeciesCode")
var result = First(filteredTable)
if(!IsEmpty(result)){
  return result.BOTANICAL
}

 

May have to adjust the field names.

R_

WilsonLee
Regular Contributor

it works!!!  thanks a lot!!!!!

🙏

0 Kudos
JPWillson
Emerging Contributor

Hello all,

I am new to Arcade/Field Maps but I am trying to do something similar except with Field 1 named "Common_Name" and Field 2 named "Botanical_Name". The table is uploaded to the same map. The table is titled "TreeNamesTable", common names are stored in the "nCommon" column while the botanical names are stored in the "nBotanical" column. I copied the solution provided above, changing the field names as appropriate, yet I am getting the following error, "Test execution error: Execution error - Invalid parameter. Verify test data." Can either one of you assist me? I have attached the code below. Thank you in advance for your assistance. 

0 Kudos