|
POST
|
Can we try the following? When running python on a class with attribute rules you must specify all the fields required by the attribute rule in the python cursor. Here is an example I have a table with three fields a,b, and c. Field c has an attribute rule return $feature.b * 2. So the rule require fields b and c Because b and c are required by the attribute rules those fields must by passed to python as follows. def update_standalone(fields):
with arcpy.da.UpdateCursor(str(gdb / 'standalone'), fields) as cursor:
for row in cursor:
row[0] += 1
cursor.updateRow(row)
print('Running')
update_standalone(['a', 'b', 'c']) # Succeeds
# passing only a will fail
# update_standalone(['a']) # RuntimeError: Failed to evaluate Arcade expression.
# passing only b will also fail
# update_standalone(['b']) # SystemError: <method 'updateRow' of 'da.UpdateCursor' objects> returned NULL without setting an error
# passing all fileds or the required fields for attribute rules will succeed
# update_standalone(['a', 'b', 'c']) # Succeeds
# update_standalone(['b', 'c']) # Succeeds
print('Done')
... View more
03-19-2024
09:58 AM
|
0
|
0
|
1669
|
|
POST
|
I think this might be a refresh issue in the table view, closing and reopening the table should refresh it (i'll make sure to log a bug to fix that) , but if you edit the map directly you can see the value changes instantly, I had this project with labeling and symbology on.. but here is a video along side the data.. works as expected
... View more
03-11-2024
01:09 PM
|
1
|
1
|
1838
|
|
POST
|
This one is really interesting, just found another issue when you have more than 6 features to update, because we have a limit of the number of Arcade engines the script hit that limit pretty soon. The only workaround to really fix this is to have an additional field, I added a field called isPush with a integer value. We want to essentially differentiate between a user update changing the pushvalue vs an automated attribute rule update. You can hide the ispush field from users as it will only be used by the attribute rule. if ($feature.ispush == 1) return {"result": {"attributes": {"ispush": 0}}}; Final script.. // calculed Field $feature.Helper
// Triggers: Insert, Update
// Exclude from application evaluation
//add base condition
if ($feature.ispush == 1) return {"result": {"attributes": {"ispush": 0}}};
if($originalFeature.pushvalue == $feature.pushvalue) return;
var GID = $feature.GemeindeID
var GLID = $feature.GlobalID
// filter current featureset except the feature that is edited rn
var SQL = "GemeindeID = @GID AND GlobalID <> @GLID"
var sirenen = FeatureSetByName($datastore, "Sirenen", ["*"])
var filterSirene = filter($featureset, SQL)
console(count(filterSirene))
var updates = []
for(var f in filterSirene) {
if(f.GlobalID == $feature.GlobalID) continue;
//don't update values that are the same to avoid recursion.
if(f.pushvalue == $feature.pushvalue) continue;
var u = {
globalID: f.GlobalID,
attributes: {
Pushvalue: $feature.Pushvalue,
ispush :1
}
}
Push(updates, u)
}
return {
result: {
attributes: {
Pushvalue: $feature.Pushvalue}
},
edit: [{
className: "Sirenen",
updates: updates
}]
}
... View more
03-08-2024
10:51 AM
|
1
|
3
|
1863
|
|
POST
|
Ok I forgot to deal with one more thing which is when the value is the same don't even attempt the update. Tested this one locally and it worked. // calculed Field $feature.Helper
// Triggers: Insert, Update
// Exclude from application evaluation
//add base condition
if($originalFeature.pushvalue == $feature.pushvalue) return;
var GID = $feature.GemeindeID
var GLID = $feature.GlobalID
// filter current featureset except the feature that is edited rn
var SQL = "GemeindeID = @GID AND GlobalID <> @GLID"
var sirenen = FeatureSetByName($datastore, "Sirenen", ["*"])
var filterSirene = filter($featureset, SQL)
console(count(filterSirene))
var updates = []
for(var f in filterSirene) {
if(f.GlobalID == $feature.GlobalID) continue;
//don't update values that are the same to avoid recursion.
if(f.pushvalue == $feature.pushvalue) continue;
var u = {
globalID: f.GlobalID,
attributes: {
Pushvalue: $feature.Pushvalue
}
}
Push(updates, u)
}
return {
result: {
attributes: {
Pushvalue: $feature.Pushvalue}
},
edit: [{
className: "Sirenen",
updates: updates
}]
}
... View more
03-08-2024
10:16 AM
|
1
|
4
|
1867
|
|
POST
|
Yeah your rule will trigger forever, just like in recursion you will need a base condition for your attribute rule. And that is if pushvalue is the same, just no-op. // calculed Field $feature.Helper
// Triggers: Insert, Update
// Exclude from application evaluation
//add base condition
if($originalFeature.pushvalue == $feature.pushvalue) return;
var GID = $feature.GemeindeID
var GLID = $feature.GlobalID
// filter current featureset except the feature that is edited rn
var SQL = "GemeindeID = @GID AND GlobalID <> @GLID"
var sirenen = FeatureSetByName($datastore, "Sirenen", ["*"])
var filterSirene = filter($featureset, SQL)
console(count(filterSirene))
var updates = []
for(var f in filterSirene) {
if(f.GlobalID == $feature.GlobalID) { continue }
var u = {
globalID: f.GlobalID,
attributes: {
Pushvalue: $feature.Pushvalue
}
}
Push(updates, u)
}
return {
result: {
attributes: {
Pushvalue: $feature.Pushvalue}
},
edit: [{
className: "Sirenen",
updates: updates
}]
} also for additional optimization (although you might have done on purpose for Editor tracking), add a filter to your sql to only push the different var pushValue = $feature.pushvalue
var SQL = "GemeindeID = @GID AND GlobalID <> @GLID AND pushvalue <> @pushValue"
... View more
03-07-2024
08:16 AM
|
0
|
6
|
1899
|
|
BLOG
|
Thanks @Bud I used file just to support older Pro releases, That being said, I just tried to upload a row mobilegdb but got an error (content type octet stream doesn't match file extension .geodatabase), the change might take time to fully propagate
... View more
02-27-2024
09:15 AM
|
1
|
0
|
1212
|
|
POST
|
There isn't an out of the box way to do it but you can script it with an options table as I show here https://community.esri.com/t5/attribute-rules-blog/how-to-toggle-constraint-and-calculation-attribute/ba-p/1387438
... View more
02-27-2024
07:38 AM
|
1
|
0
|
1063
|
|
IDEA
|
There isn't an out of the box way to do it but you can script it with an options table as I show here https://community.esri.com/t5/attribute-rules-blog/how-to-toggle-constraint-and-calculation-attribute/ba-p/1387438
... View more
02-27-2024
07:35 AM
|
0
|
0
|
1964
|
|
BLOG
|
We hear this requirement very often from customers in geonet and the conferences; Is there a way to temporarily disable all immediate attribute rules? While out of the box there isn't a way to do that as it requires changing the schema (physically disabling each rule and stopping any services), I thought I'd share a workaround for users who really want to implement this in their system. By adding an "options" table with a column EnableAR, we can have each rule before it executes checks this table and reads the value at runtime. If the value is 0 the rule immediately returns, if the value is 1 the rule logic executes as normal. I made an example here (attached) and a video to demonstrate With this approach you can quickly toggle all attribute rules execution and you can even control what type rules you want to enable and disable. The downside of this is you have to update all your rules to start using this check, but once you do you are good to go. The other thing to watch out for is in multi-user environment one user can toggle this option to disable the rule and post it to DEFAULT effectively disabling the rules for all users which is something you might not want. You can of course add additional checks to prevent this logic in DEFAULT using the gdbVersion function. Filegdb with code attached
... View more
02-27-2024
07:34 AM
|
2
|
4
|
2025
|
|
POST
|
Thanks I can reproduce it looks like a bug when the association is being added in multiple payloads, we will take a look. Meanwhile the workaround is to group all associations in one payload. return {
"edit": [
{
"className" : "ElectricDistributionJunctionObject",
"adds" : [{
"tag": "unit1",
"attributes": {
"assetgroup": 2,
"assetType": 1}
}]},
{
"className": "^UN_Association",
"adds": [{
"fromClass": "ElectricDistributionJunctionObject",
"fromGlobalId": $feature.GLOBALID,
"toClass": "ElectricDistributionJunctionObject",
"toGlobalId": "unit1.globalID",
"associationType": "containment"
},
{
"fromClass": "ElectricDistributionJunctionObject",
"fromGlobalId": $feature.GLOBALID,
"toClass": "ElectricDistributionJunctionObject",
"toGlobalId": "unit1.globalID",
"fromTerminal": "Source",
"associationType": "connectivity"
},
{
"fromClass": "ElectricDistributionJunctionObject",
"fromGlobalId": $feature.GLOBALID,
"toClass": "ElectricDistributionJunctionObject",
"toGlobalId": "unit1.globalID",
"fromTerminal": "Load",
"associationType": "connectivity"
}
]},
]
}
... View more
02-19-2024
10:25 AM
|
0
|
2
|
1168
|
|
POST
|
No known issues in 3.2, all scripts should just work. Looking at the code I see you are using a variable LBCode where it is not defined, this might be a bug in 3.1 that we fixed in 3.2 (we start detecting undefined variables), you might have meant to use attributeValue instead. thanks I would suggest for performance avoiding using the count here and just do first and check for null and only ask for you are using. here is the rewritten script with the LBCode fixed. var intersectLayer = FeatureSetByName($datastore, "Lsgd_Boundary", ['LBCode'], false);
var attributeName = 'LBCode';
var intersectingFeatures = Intersects(intersectLayer, $feature);
var intersectedFeature = First(intersectingFeatures);
if (intersectedFeature == null) return 'NA';
var attributeValue = intersectedFeature[attributeName];
// Generate a unique sequence number
var id = NextSequenceValue("uniqueid");
// Concatenate LBCode and the unique sequence number
var projectID = attributeValue + "-" + id;
return projectID;
... View more
12-27-2023
08:38 AM
|
1
|
2
|
1701
|
|
POST
|
Good question and yes that is the split contract as we have written it for consistency . The longer piece gets the "update" of the geometry while the shorter one gets to be inserted that is why the shorter one gets the new ID because that is where the logic to generate id lives.
... View more
11-01-2023
03:04 PM
|
0
|
0
|
2263
|
|
POST
|
hey Katherine i see this is a direct connect sde connection, can you try on a filegdb and see if you see the same behavior? and also is it possible to send a data (with just one "bad" polygon) that reproduces feel free to take any fields/ data that is not relevant. your code looks correct so my guess it might be the spatial reference ..
... View more
09-08-2023
12:30 PM
|
0
|
1
|
3338
|
|
POST
|
So you want to add a constraint rule on the attachment table that says something like this if ($feature.DATA_SIZE > 1000) return false;
return true;
... View more
09-07-2023
12:26 PM
|
0
|
1
|
1045
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 2 weeks ago | |
| 5 | 3 weeks ago | |
| 1 | 4 weeks ago | |
| 1 | 11-03-2025 12:32 PM | |
| 1 | 01-02-2025 06:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|