Hi
I am using arcade code to count attachments and save in field, but
Count(Attachments(item));
but I get the following error:
invalid arcade expression, arcade error: expected attachment type, script line: 4
I'm using ArCGIS pro 2.9.11 and enterprise 2.9.1
My attribute rule:
var features = FeatureSetByName($datastore,'FeatureClass', ['*'], false);
var gid=$feature.REL_GLOBALID;
var item=First(Filter(features, 'globalid = @gid'));
var count = Count(Attachments(item));
if ($editcontext.editType == 'DELETE'){
var count_total=count-1
} else {
var count_total=count
}return {
'edit': [{
'classname' : 'FeatureClass',
'updates' : [{
'globalid': gid,
'attributes' : {'Adjs' :count_total }
}]
}]
}
I have tried the same Count(Attachments()) line and it is valid arcade for calculated fields.
Thanks!
Hey @geopamplona
I found a post from a while back that somewhat matches what you have: https://community.esri.com/t5/arcgis-online-questions/arcade-count-attachments-in-related-table/td-p...
I was curious if you could try to do:
var features = FeatureSetByName($datastore,'FeatureClass', ['*'], false);
var gid=$feature.REL_GLOBALID;
var item=First(Filter(features, 'globalid = @gid'));
var cnt = 0
for(var item in features) {
cnt += Count(Attachments(item))
}
if ($editcontext.editType == 'DELETE'){
var count_total=cnt-1
} else {
var count_total=cnt
}
return {
'edit': [{
'classname' : 'FeatureClass',
'updates' : [{
'globalid': gid,
'attributes' : {'Adjs' :count_total }
}]
}]
}
This is just a rough rendition so I hope it can provide some help!
Cody