Skip to main content
Question

Automatically Delete File Attachments Upon Data Change

  • March 21, 2019
  • 0 replies
  • 53 views

This question is a follow-up to: https://community.quickbase.com/quickbase/topics/delete-file-attachment-with-api-editrecord. I was wondering if there was a way to automatically delete file attachments when another field changes. Would I use a webhook? I've never had to use one before. Basically, I have 10 Picture fields, and when the status of a job changes, the pictures are no longer needed, and I would like to get rid of them to minimize my file storage usage. Anyone know how I can automatically delete all those pictures when the status of my job changes?

They mentioned in the last post that to delete attachments you had to use:

&_fid_9=

&delfile_fid_9=1

In case you need to know:
Status Checkbox Validation: rid=410
Picture #1: rid=6
Picture #2: rid=26
Picture #3: rid=27
Picture #4: rid=28
Picture #5: rid=29
Picture #6: rid=30
Picture #7: rid=31
Picture #8: rid=32
Picture #9: rid=33
Picture #10: rid=34

  • Quickbase Alumni
  • March 22, 2019
Yes - your best approach will be to use a Webhook in this instance and have it triggered when your trigger field changes. Your XML request is actually copied in the link you provided, I tweaked it a little to bring it up to today - you would simply expand it for all the fields where I stopped

<qdbapi>
   <usertoken>usertoken goes here</usertoken>
     <rid>[record_id]</rid>
  <field fid="6" filename="delete"></field>
  <field fid="26" filename="delete"></field>
  <field fid="27" filename="delete"></field>
**<insert the rest of your fields here>**
</qdbapi>

For more detail - the above is what you would put in the 'Message Body' - as the detail for what you want to do

Your endpoint URL would be the table in which you're doing the edit record, so probably the same table the webhook is in

HTTP Method is POST
Message Format is XML
Your message header would be 
   key: QUICKBASE-ACTION
   value: API_EDITRECORD


Chayce Duncan | Technical Lead
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base

  • Author
  • Quickbase Alumni
  • March 25, 2019
Thanks! I'll give this a try!