Webhook or action to create parent record on child import

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
  • (Edited)
We have a temporary app where order records (line items) are imported into a table. I am trying to use an action/webhook (since I can't program Javascript) to create the parent record so that I can create summaries of records that meet certain requirements.  Summary Tables are somewhat helpful, but are showing great limitations in what I'm trying to accomplish.

I tried an action to create a record but got an error stating I was using non-unique values...I thought after it added the first record via the action it would simply update it if the second line had the same record ID. Instead it threw an error. (API_ImportFromCSV) If you use update record instead of import or add and the record ID doesn't exist will it create it?
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Can you describe your ACTION setup?
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
When order line is added, then add a record to the parent table.
Values: Copy the value from "Order Number MOS" which is a formula field that holds the order number to "Master Order Number" which is the Key Field of the parent table. In my test data, I through error 51. because I had two lines that had the same order number (because an order can have multiple lines). I was hoping it would just overwrite the new record...but I think Add has to be unique.?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Hmm, I don't know if that can be made to work, but before we give up a nice native solution,  one thing to try would be to have a field on the Parent called [Parent Exists?] as a formula checkbox field with a formula of true.  just type true on the box.

Then look that up down to the child table.

Then add a condition on the ACTION to not fire of the [Parent exists?] is checked.
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
IT seems that it checks the criteria one time then ran the entire thing instead of each time it was going to add a record..
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
so the same error occurred.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 49,562 Points 20k badge 2x thumb
OK, so I suggest we abandon that approach and move to Plan B.  But my plan B is pretty manual.

Make a Summary Report of Order Lines where [Parent Exists?] is unchecked.  Group by group by [Order Number MOS]

Then use More ... and copy these to another table and navigate to the app itself again and then to the orders table.

You can then subscribe to receive that report daily so you remember to make the parents.
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
It seems as though webhooks/actions should be able to either a) add the record or b) update if it already exists?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
I think that the issue is that even if you manually import a CSV file with a duplicate Key within the imported data, it will fail.  

Yes, if the Key exists it will update and if the Key does not exists it will add.  But if you try to import data with duplicates within the import set in the Key it will fail, so I think that the ACTION / WEBHOOK is just an automated version of the manual process.

So, I don't know how to do that without a script as they would need to be added one by one after checking if they exists or else added one by one one record at a time so that there is no way that the import record set of 1 record can have duplicates within the set.
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
Thanks. So Manual it is until I get frustrated enough to get a script written. Thanks for the education :)