Discussions

 View Only
  • 1.  Automatically Delete File Attachments Upon Data Change

    Posted 03-21-2019 18:28
    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



  • 2.  RE: Automatically Delete File Attachments Upon Data Change

    Posted 03-21-2019 20:55
    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


  • 3.  RE: Automatically Delete File Attachments Upon Data Change

    Posted 09-25-2019 14:19
    ​Hi!
    I am revisiting this after having to hold off on it to do some other things, but after setting it up, it doesn't seem to be working through the way I need it. So, the status change happens in another table. There's the work request table that hold records of poles from the poles table then there's the field work table that hold the field data for poles. It is set up this way because all these tables weren't set up at the same time. 

     

    The way I have it set up right now is that when the status changes to a specific value in the work requests table then I have an automation set to check a checkbox within the field work table which is where the pictures of the poles I want to delete are and where the webhook is located. The webhook works if I manually check the checkbox in the field work table, but it doesn't work if the automation changes the checkbox.  

    Any suggestions?

    ------------------------------
    Jordan McAlister
    ------------------------------



  • 4.  RE: Automatically Delete File Attachments Upon Data Change

    Posted 03-25-2019 12:39
    Thanks! I'll give this a try!