Attribute rules for enforcing attachments?

1925
13
01-27-2020 04:27 AM
AndrewZimba1
New Contributor III

When building services for Collector with feature classes in an enterprise gdb, are attribute rules the appropriate mechanism for enforcing the inclusion of a .jpg attachment to a point and returning an error message if a save attempt is made without such an attachment?

0 Kudos
13 Replies
XanderBakker
Esri Esteemed Contributor

Thanks Hussein Nasser for clarifying this. I was aware of the requirement of the EGDB but not of the part that branch versioning was required. Good to know!

Will you be at the distributor UN workshop next week in Redlands? If so, see you there.  

0 Kudos
AndrewZimba1
New Contributor III

One more question about attribute rules in general - will they work in collector when using it in offline mode?

0 Kudos
HusseinNasser2
Esri Contributor

No they will not work in Collector in offline mode, that is because when we download the data offline the Attribute Rules are not coming back with the data. They will only work on online mode and will be triggered on the server side.

In the future releases we will have the capability for Collector and other ArcGIS Runtime applications to download Attribute Rules and execute them locally offline. It is a big project that is in the works

geopamplona
New Contributor III

Hi @HusseinNasser2 

I am using the code that was shared here but I got an unexpected error:

geopamplona_0-1704887592819.png

 

I get the following error
invalid arcade expression, arcade error: expected attachment type, script line: 4

 

My attribute rule:

var features = FeatureSetByName($datastore,'SewerLine', ['*'], 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' : 'SewerLine',
'updates' : [{
'globalid': gid,
'attributes' : {'NumAdjuntos' :count_total }
}]
}]
}

I have tried the same Count(Attachments()) line and it is valid arcade for calculated fields.

 

I'm using ArCGIS pro 2.9.11 and enterprise 2.9.1

 

Thanks!

0 Kudos