Add or Update API Calls with a unique key.

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

When importing records from CSV it works on the basis of Adding New records, and updating existing records, providing you import to the key field.

I'm wondering if the same be done with the Add or Edit Record API calls?

Thanks

David

Photo of David

David

  • 60 Points

Posted 3 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 65,806 Points 50k badge 2x thumb
I'm not sure of your relationships, but if you can arrange for the record being added or edited to be the Parent of the record that you are on, which I typically do is to create a checkbox formula field on the Parent called [Parent exists?] with a value of true. Then I look that up to the child record and use either the Add or Edit API based on an IF statement.
Photo of David

David

  • 60 Points
Hi - thanks for the feedback. My use case is the other way around, so this won't work. External users can add records via a public web form - I'm thinking of using the API with webhooks, to create a parent record if one doesn't already exist. I'll use the email address as the key field, linking the parent to each child. Obviously if the parent already existing for that email address it shouldn't create another. Thinking out loud, I'm wondering if this will work just by setting the email address field in the parent record to unique so that attempts to create parents with duplicate email addresses will fail. I'll give that a go tomorrow. D
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,806 Points 50k badge 2x thumb
I would guess a Webhook would just silently fail if the email existed. Which is perfect for your goal. I suppose that you could fire off two of them, one to add and one to edit.
Photo of David

David

  • 60 Points
Thanks - I'll give this a go and update if I manage to get it working.

D