Select to view content in your preferred language

Auto populate related table with parent feature attributes

248
4
09-19-2024 01:56 PM
WFCAdmin
Emerging Contributor

If you could help me with this I would be extremely appreciative!

I am working in Field Maps

Field staff will make multiple trips to sample sites throughout the year. Each time they stop at a sample site they will need to collect data to a table that has been related to a parent feature.

The parent feature is a point layer called "qPCR_Sites"

The related table is called "qPCR_Samples"

The parent feature has 14 different attributes that should be auto-populated to each collected record. These will not need to be edited and can be hidden.

Field staff will fill out 5 additional fields in the table during each sample session. ( I have this part handled)

I am trying to figure out the expression needed to auto-populate the 14 different attributes from "qPCR_Sites" to "qPCR_Samples".

The first attribute I am trying to tackle is the field "Analyze_for" It is stored as "Analyze_for" in both the "qPCR_Sites" attribute table and the related "qPCR_Samples" table.

Thank you!


Aaron

 

Can anyone help me with the appropriate expression?

 

 

0 Kudos
4 Replies
CooperCarlisle
Emerging Contributor

Hi Aaron,

I am no expert, but this is what I came up with.. let me know if this helps!

 

// Get the related feature from qPCR_Sites
var parentFeature = FeatureSetByRelationshipName($feature, "qPCR_Sites", ["Analyze_for"], true);

// Check if there is a related feature
if (Count(parentFeature) > 0) {
// Return the "Analyze_for" value from the related qPCR_Sites feature
var site = First(parentFeature);
return site["Analyze_for"];
} else {
// If no related feature is found, return null or an empty value
return null;
}

0 Kudos
WFCAdmin
Emerging Contributor

Thank you so much for looking into this!

Unfortunately, I am getting

"Test execution error: Execution error - Invalid parameter. Verify test data."

0 Kudos
WFCAdmin
Emerging Contributor

Thank you so much!!!

With your help I was able to get to the following formula which is working for me!

 

var parentFeature = FeatureSetByRelationshipName($feature, "qPCR_Sites", ["Analyze_for"])
var feature = First(parentFeature);
if (!IsEmpty(feature)) {
  return feature["Analyze_for"]
} else {
return null
}
0 Kudos
aaron_tob
Emerging Contributor

You might also consider setting up Domain rules for the fields of interest in ArcGIS Pro, and providing default values. Those values should auto-populate when submitting new records. If you don't want to republish the whole thing though, this is an interesting approach. Glad to hear it's working out!

0 Kudos