Select to view content in your preferred language

Autofill fields on mobile from a related table based on a one-to-one relationship

349
5
Jump to solution
04-26-2024 12:36 PM
jmcdonald_sdi
New Contributor II

I'm trying to configure a empty asset points layer in ArcGIS Pro that I can collect on that, once a unique ID found on the asset is entered in the top form field,  will pull and autofill all of the point layer fields from a corresponding row that exists in a related table based on that unique ID.

I know I can do a simple spatial join on the unique ID field once I collect all or a subset of the asset points, but there's a project constraint that necessitates the data being joined simultaneously while the asset is collected.

0 Kudos
1 Solution

Accepted Solutions
KerriRasmussen
Esri Contributor

Hi @jmcdonald_sdi . Sorry for the delay. I did some testing and was able to get it to work. Here is the expression I used, you will need to update with your data. Please let me know if you have any questions.

//get facility ID value
var facilityID = $feature.Facility_ID__Mix_

//Use FeatureSetByName to find related table, this will show $map, "FeatureName - TableName"
var relatedRecords = FeatureSetByName($map, "FeatureName - TableName")

//Filter by unique facility ID
var facilityIDrecords = Filter(relatedRecords, "Facility_ID__Mix_ = @facilityID")

//Use first record found in filter
var FirstRecord = First(facilityIDrecords)

//return the first record attribute, add your field name after the .
return FirstRecord.YourFieldName
 

View solution in original post

0 Kudos
5 Replies
KerriRasmussen
Esri Contributor

Hi @jmcdonald_sdi ! Can you tell me more about your workflow? I'm assuming that your point layer is completely blank and doesn't contain points, can you confirm? 

0 Kudos
jmcdonald_sdi
New Contributor II

Yes, point layer is completely blank. I want to collect location points and photos to "enrich" a non-spatial table of assets that were collected recently.

My intended workflow is to have the field crews enter a physical ID from the asset as the first field of a form, this action would trigger a check of the related table using that unique ID. If the ID entered matches one found on the related table, it automatically fills in the rest of the form with the corresponding data from that specific row on the related table. From there, the crew can confirm all those attributes on the form and save the new asset point.

I put the point layer and the asset data table in a fresh geodatabase and created a one-to-one relationship class on the field that contains the physical ID found on the asset. I then published the point layer to AGOL to try to see if the table would show up in the related records tab in Field Maps designer.

The table shows up in field maps designer with the layer but I can't configure the point layer to pull data from the table. I can see the point layer as a related record for the asset table but I don't see the table as a related record on the point layer. Maybe this has to with the point layer being blank.

Any input or advice would be greatly appreciated.

0 Kudos
jmcdonald_sdi
New Contributor II

Here's my Arcade expression that should work but doesn't:

// Get the text input value from the Facility_ID__Mix_ field
var userInput = $feature.Facility_ID__Mix_;

// Define the related records using the CM_Integrated_TEST relationship
var relatedRecords = FeatureSetByRelationshipName($feature, "CM_Integrated_TEST");

// Check if there are any related records
if (IsEmpty(relatedRecords)) {
  // Handle the case where there are no related records (optional)
  return "No related records found";
} else {
  // Loop through the related records
  for (var row in relatedRecords) {
    // Get the value of the unique ID field (updated variable name)
    var relatedID = row.Facility_ID__Mix_;
   
    // Check if the text input matches the unique ID
    if (userInput === relatedID) {
      // Fields match, return the entire related record
      return row;
    }
  }
 
  // Fields don't match in any related records
  return "No match found for ID: " + userInput;
}
0 Kudos
KerriRasmussen
Esri Contributor

Hi @jmcdonald_sdi . Sorry for the delay. I did some testing and was able to get it to work. Here is the expression I used, you will need to update with your data. Please let me know if you have any questions.

//get facility ID value
var facilityID = $feature.Facility_ID__Mix_

//Use FeatureSetByName to find related table, this will show $map, "FeatureName - TableName"
var relatedRecords = FeatureSetByName($map, "FeatureName - TableName")

//Filter by unique facility ID
var facilityIDrecords = Filter(relatedRecords, "Facility_ID__Mix_ = @facilityID")

//Use first record found in filter
var FirstRecord = First(facilityIDrecords)

//return the first record attribute, add your field name after the .
return FirstRecord.YourFieldName
 
0 Kudos
jmcdonald_sdi
New Contributor II

Hey Kari,

This code worked perfectly with your changes:

//get facility ID value
var facilityID = $feature.Facility_ID__Mix_

//Use FeatureSetByName to find related table, this will show $map, "FeatureName - TableName"
var relatedRecords = FeatureSetByName($map, "CM Integrated TEST")

//Filter by unique facility ID
var facilityIDrecords = Filter(relatedRecords, "Facility_ID__Mix_ = @facilityID")

//Use first record found in filter
var FirstRecord = First(facilityIDrecords)

//return the first record attribute, add your field name after the .
return FirstRecord.Source


Thanks so much,

Jack