Is there a way to mass-delete attachments that were generated with the document builder ?automation?

Almonto1
Almonto1 ✭✭✭✭

I previously created a document mapping automation that attached a personalized report to each row of data, but it now requires edits. Is there a way to delete the old auto-generated attachments in one go without deleting the other attachments? If not, I'll have around 2 thousand rows to delete attachments from 1 by 1, so any assistance is appreciated!

Answers

  • jmyzk_cloudsmart_jp
    jmyzk_cloudsmart_jp Community Champion

    Hi @Almonto1

    Yes, there is a way β€” but you need to use the Smartsheet API.

    Here’s the overview:

    1. Use List Attachments API method to retrieve all attachments for the sheet.
    2. Check the Created By field. If created_by.name is "Smartsheet Automation", you can assume it was generated by the document builder. (*)
    3. Use the Delete Attachment method to delete those attachments one by one.
    4. Important: Since you have over 2000 rows, and Smartsheet does not allow bulk delete of attachments, you will need to make one API call per deletion.
    5. If you want help setting this up, feel free to contact me.

    (*) Sample List Attachments Response

    The first attachment is by me. The second attachment is by document builder automation.

    Attachment ID: 7052208425963396, Name: Attachment to cell image test.pdf, Created by: jmiyazaki
    Attachment ID: 1304140950835076, Name: Mapping for ζ—₯本θͺžγƒ•γ‚©γƒ³γƒˆ.pdf, Created by: Smartsheet Automation

    https://developers.smartsheet.com/api/smartsheet/openapi/attachments (Smartsheet API Documentation on Attachments)

    Test code and result

    image.png

    image.png