Accessing attachments of an object using a custom widget

04-17-2024 01:45 AM
New Contributor II


I'm looking to build a custom widget where the user will select a feature layer (in this case points collected on site).

From this I want to make a table which will show the OID  of the point, other field values but most importantly, a sum of the attachments at that point.

How can this be done through the custom widgets? Currently able to access this information through arcpy using 


for feature in features:
    oid = feature.attributes['OBJECTID']

    attachments_info = layer.attachments.get_list(oid=oid)

    if attachments_info:
        for attachment_info in attachments_info:
            att_id = attachment_info['id']
            filename = attachment_info['name']
            attachment_list.append({'OID': oid, 'AttachmentID': att_id, 'Filename': filename})

attachment_df = pd.DataFrame(attachment_list)


This is returning a dataframe with the OIDs and their attachments. I would like to achieve something similar in a custom widget.



0 Kudos
1 Reply
MVP Regular Contributor

You won't be able to use arcpy because Experience Builder is written in Javascript, not Python. But it does have access to the Javascript API. You should be able to access the attachments through the queryAttachments() method of the featureLayer.

GIS Developer
City of Arlington, Texas
0 Kudos