Hello ArcGIS Community,
I am currently working on an Arcade script for an Insert trigger, and I'm facing some challenges. Your expertise and guidance would be immensely valuable to help me troubleshoot and refine my script.
I look forward to your responses and appreciate your time and support.
Thank you!
Objective:
I am developing a Survey123 app that points to an enterprise layer named `BCCpointclass` within ArcGIS Enterprise, not a hosted layer in AGOL. Each time a new point is created in the survey, I want to use an attribute rule on BCCpointclass to create a duplicate of a newly created point and all its attributes in another enterprise point feature class named `BCC_JuneSnapShot`.
Issue:
From the script below in the expression builder I get the error. "Invalid expression. Error on line 20. Identifier expected.
I put a script together from the example in this 2019.
This is my script:
// Get the global ID of the point feature being inserted
var globalId = $feature.globalid;
// Find the corresponding feature in the BCC_JuneSnapShot feature class
var snapshotFeatureClass = FeatureSetByName($datastore, "BCC_JuneSnapShot");
var filteredFeatures = FeatureSet(
Filter(snapshotFeatureClass, "pointGuid = @globalId")
);
// If no matching feature is found, create a new feature
var newFeature;
if (Count(filteredFeatures) == 0) {
// Create a new feature in BCC_JuneSnapShot
newFeature = snapshotFeatureClass.createFeature();
// Set the geometry and attributes from BCCpointclass to BCC_JuneSnapShot
Set(newFeature, 'geometry', $feature.geometry);
for (var field in $feature) {
if (field !== 'geometry') {
newFeature[field] = $feature[field];
}
}
// Save the new feature in BCC_JuneSnapShot
snapshotFeatureClass.addFeature(newFeature);
} else {
// If a matching feature exists, exit without making changes
return $feature.field;
}
// Return the value of the field 'Field' without change
return $feature.field;