Hello,
We have two feature classes A & B in enterprise geodatabase environment. They are participating in a relationship class.
A - Projects
B- Sewer upgrades
Our goal/requirement is to automatically update the common attributes on existing features in B if the same attribute fields are updates in A.
To accomplish this, base on the example available here, I came up with following (immediate calculation rule on A):
//s1 - get all the features from sewer upgrades feature class
var destination = FeatureSetByName($datastore, "GEO_DB.ENG_SD.SewerUpgrade", ["DBNUMBER","TECH_REV", "CONS_ST", "CONS_ED", "EST_CON_DUR", "STATUS"], false);
//s2 - get dbnumber edited in the projects developments feature class
var dbnumber = $feature.DBNUMBER;
//s3 - filter feature based on the existing edit
var match = Filter(destination, "DBNUMBER = @dbnumber");
//s4 - update records in sewer upgrades
var sewerupgradelist = [];
var counter = 0;
var numfeatures = Count(match);
if (numfeatures > 0) {
for (var feature in match) {
sewerupgradelist[counter] = {
'OBJECTID' : feature.OBJECTID,
'attributes' : {
'CONS_ST' : $feature.CONS_ST,
'CONS_ED' : $feature.CONS_ED,
'EST_CON_DUR' : $feature.EST_CONS_DUR,
'TECH_REV' : $feature.TECH_REV,
'STATUS' : $feature.STATUS
}
}
counter++
}
return {
'result' : numfeatures + ' sewer upgrades features found.',
'edit' : [{
'className' : "GEO_DB.ENG_SD.SewerUpgrade",
'updates' : sewerupgradelist
}]
}
}else {
return 'No features found under sewer upgrade with matching DBNUMBER.'
}
While there are no validation errors, ArcGIS Pro comes up with following error during testing:
Any help in resolving the issue will be appreciated.
Solved! Go to Solution.
According to the documentation of the attribute rule dicitonary keywords ,
So, try this:
//s1 - get all the features from sewer upgrades feature class
// you only need DBNUMBER (to filter) and OBJECTID (to send edits)
var destination = FeatureSetByName($datastore, "GEO_DB.ENG_SD.SewerUpgrade", ["DBNUMBER","OBJECTID"], false);
//s2 - get dbnumber edited in the projects developments feature class
var dbnumber = $feature.DBNUMBER;
//s3 - filter feature based on the existing edit
var match = Filter(destination, "DBNUMBER = @dbnumber");
//s4 - update records in sewer upgrades
var sewerupgradelist = [];
var counter = 0;
for (var feature in match) {
sewerupgradelist[counter] = {
'objectID' : feature.OBJECTID,
'attributes' : {
'CONS_ST' : $feature.CONS_ST,
'CONS_ED' : $feature.CONS_ED,
'EST_CON_DUR' : $feature.EST_CONS_DUR,
'TECH_REV' : $feature.TECH_REV,
'STATUS' : $feature.STATUS
}
}
counter++
}
return {
// only use this if you have set a text field as return field for the rule
// 'result' : numfeatures + ' sewer upgrades features found.',
'edit' : [{
'className' : "GEO_DB.ENG_SD.SewerUpgrade",
'updates' : sewerupgradelist
}]
}
Hello Raj-Chavada,
I'm not sure this is the reason for the error message, but I see something I'd like to ask about:
At Line 2, in your field list, I see 6 fields: "DBNUMBER", "TECH_REV", "CONS_ST", "CONS_ED, "EST_CON_DUR", and "STATUS"
In Lines 20-25, I see 6 fields: 'CONS_ST', 'CONS_ED', 'CONS_ST', 'EST_CON_DUR', 'TECH_REC', and 'STATUS'
What do you think?
Regards,
Mike
Thanks, Mike! Please see my reply below:
RC: No. This is an error on my part. Removed the extra line.
RC: I am not referencing 'DBNUMBER' because that attribute field not required to be updated.
According to the documentation of the attribute rule dicitonary keywords ,
So, try this:
//s1 - get all the features from sewer upgrades feature class
// you only need DBNUMBER (to filter) and OBJECTID (to send edits)
var destination = FeatureSetByName($datastore, "GEO_DB.ENG_SD.SewerUpgrade", ["DBNUMBER","OBJECTID"], false);
//s2 - get dbnumber edited in the projects developments feature class
var dbnumber = $feature.DBNUMBER;
//s3 - filter feature based on the existing edit
var match = Filter(destination, "DBNUMBER = @dbnumber");
//s4 - update records in sewer upgrades
var sewerupgradelist = [];
var counter = 0;
for (var feature in match) {
sewerupgradelist[counter] = {
'objectID' : feature.OBJECTID,
'attributes' : {
'CONS_ST' : $feature.CONS_ST,
'CONS_ED' : $feature.CONS_ED,
'EST_CON_DUR' : $feature.EST_CONS_DUR,
'TECH_REV' : $feature.TECH_REV,
'STATUS' : $feature.STATUS
}
}
counter++
}
return {
// only use this if you have set a text field as return field for the rule
// 'result' : numfeatures + ' sewer upgrades features found.',
'edit' : [{
'className' : "GEO_DB.ENG_SD.SewerUpgrade",
'updates' : sewerupgradelist
}]
}
Thank you so much! This worked. Accepting as solution.