Summary
In ArcGIS Pro, file attachments, such as documents and images, can be added to feature classes. They are stored in a geodatabase feature class attachment table and linked to individual features. Refer to ArcGIS Pro: Add or remove file attachments for more information.
This article provides the workflow to limit the size of file attachments in a feature class in ArcGIS Pro. This method is useful when limiting the size of attachments, for example images, for newly created features on a map.
Procedure
- Open the ArcGIS Pro project.
- Enable attachments for the feature class.
- In the Catalog pane, expand Databases and the feature class geodatabase.
- Right-click the feature class attachment table and click Data Design > Attribute Rules to open the Attribute Rules view.
- Add a constraint rule to the attachment table.
- In the Attribute Rules view, on the Constraint tab, click Add Rule.
- In the details pane of the rule, specify a name for Rule Name.
- Specify a description of the rule for Description.
- Click the Expression icon to open the Expression Builder window.
- In the Expression Builder window, in the expression box, type the following expression. Replace <dataSizeField> with the name of the data size field in the attachment table, and replace <dataSize> with the maximum size of data (in bytes) for attachments in the feature layer.
if ($feature.<dataSizeField> > <dataSize>) return false;
return true;
The code block below shows the full working expression.
if ($feature.DATA_SIZE > 2000000) return false;
return true;
Note:
The units of the data size field in the attachment table is in bytes. For example, a value of 2,000,000 is equal to 2MB.
- Click the Verify icon to verify the expression, and click OK.
- In the details pane of the rule, specify a number for Error Number, and specify a message for Error Message.
- Check the Insert check box under Triggers.
- On the top ribbon, click Save.
The image below shows an error message returned when adding an attachment to a feature if the file size is larger than the limit specified in the constraint rule.