webhook to edit record it that was just created

  • 1
  • 3
  • Question
  • Updated 11 months ago
  • Answered
  • (Edited)
I'm trying to use a dynamic form rule to auto assign a unique tracking number based on several fields. One of those being the Record ID. When a new record is saved, the dynamic form rule triggers prior to the Record ID being assigned. As a result, I have to save the record a second time to get the value I'm looking for in the unique tracking number field. Perhaps I need a webhook to trigger directly after the record is saved to modify my record again to trigger the dynamic form rule so it can capture the newly assigned Record ID? I want to prevent asking my users to save a record twice in order to see their tracking number.

*Forgot to mention, I'm unsure how to create webhooks for this purpose
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
  • Frustrated at my own inability to solve this

Posted 11 months ago

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

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
Before I get into Actions and Webhooks, may I ask why you don't just make this Unique Tracking number field be a formula field?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,754 Points 20k badge 2x thumb
Forget about using webhooks or form rules for the moment and just describe how the unique tracking number is formatted.
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
This app was populated with a lot of old data from an Access Database that had it's own numbering system.  I use another field to determine if an old number exists or not. If an old number does not exist, than it uses the new auto generated number value with the Record ID. Below is a list of field names and what they do.

List of Field Names:
OId ARB # - this is a text field only populated if it was from the old database, blank otherwise
Auto ABR# - this is a formula field that concatenates Location and Record ID together
New True ABR# - this is a formula field that looks for a value in Old ABR #, otherwise returns Auto ABR#
ABR Number - this is just a text field that waits for the dynamic form rule to "stamp" the value in the New True ABR# upon save. This is my primary key.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
You can use an Action to do this.  Action are what I like to think of as Webhooks for Dummies and I will take a dummies solution over complicated syntax any time I can.

But one trick is that on first look, it will not appear that an Action can edit the record that you are on.  I seems to only have functionality to add a record on another table or else edit "child" records.

But you can create a Report Link field type on the Record and connect the [Record ID#] on the left side with navigating to the same app, same table same [Record ID#] field on the record you are on.  That is allowed to be your Report link field for an Action.

Then set the Action to fire only when the [New True ABR#] changes and after the save the [New True ABR#] is not equal to the [ABR Number]

Give it a try.

Note also that the Action, like a webhook,  will fire a split second after the record has already started to re-display on the screen after a save.  So while initially it may seem that the action did not fire, in fact if you F5 refresh the screen in View mode, you will see that it did fire.
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
I'm trying to follow your suggestion but I'm coming up with a 400 error message so I'm trying to trouble shoot. I appreciate your explanation and you've solved my issue I found with the Action which you identified as the ability to add a new record or modify a related child record. I'm hoping to figure out my error and posting a success statement soon. Thanks!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
I'm confused.  Are you using an Action or a webhook?  If an action, what is the explanation or the error 400 error code when you expand the box?
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
I built an Action and after saving a record I receive an e-mail with the following information -->

There's a problem with a webhook in the ABRs table.

Starting at 10:54 AM on 01-02-2018, webhook Quick Base Action #1 had the following problem:

400 Error: <?xml version="1.0" ?> <qdbapi> <action>API_EditRelatedRecords</action> <errcode>52</errcode> <errtext>Trying to import more than one column to the same field</errtext> <errdetail>You attempted to import more than one column of data into the same field:<BR/> &quot;ABR Number&quot;</errdetail> <num_recs_updated>0</num_recs_updated> <num_recs_unchanged>0</num_recs_unchanged> </qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
is your Action doing what the error message says you are doing?
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
Not sure, the data seems to be saved from the initial input on the form. The record isn't saving a second time so the [New True ABR#] isn't being pushed to the [ABR Number]. I'll dive into this tonight to figure it out.
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
After trying several different options, I'm able to get the QB Action to trigger and have it take the value in the [New True ABR#] and paste it into [Old ABR#] successfully. However, it's still not prompting the Dynamic Form Rule to modify the value in the [ABR Number] field. When I try to have it stamp the value in the [ABR Number] field, that is where it returns the error message I had posted previously. What's interesting is that the Action is firing after the Record ID is generated, so not sure why it's not triggering the Dynamic Form Rule.
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,214 Points 5k badge 2x thumb
Hi Lee,

Dynamic Form Rules only fire when a record is opened in a specific form while being edited. It doesn't typically work off of Actions, Webhooks, and functions like Grid Edit where no specific form is being used but instead the data is being worked with outside of a Form. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
Dynamic Form Rules will only fire when a human user manually edits a form in a browser window and saves.

Can you confirm which field is the Key field is to this table?  Is it the [Record ID#] field?

 
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
I've modified my key field to be the [ABR Number] field. Since I will no longer have any new "Old" records, all [Auto ABR #s] will have the Record ID contained in them making sure the [ABR Number] field is unique. However, I'm relying on the dynamic form rule to post the value in the [New True ABR#] to the [ABR Number] field after saving. I've not yet been successful having the QB Action modify the [ABR Number] field.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
Can you remind me why the Key field needs to be the [ABR Number] field and not just the [Record ID#] field.

The Action will not be able to work in this situation since the Action fires only after the record is saved, but the save cannot cannot fire successfully since the Key field is blank for new record and blank is not a valid value for a Key field.
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
I believe I built it this way so I could use that in my table relationships. Since I was importing old data from an old Access Database, I had the [ABR Number] in all my Access tables. This connected my data quickly without having to assign a related value. Perhaps there is a better way to do this.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
If there is no more Old data ever going to come into the app, you could change the Key field back to Record ID#, and then the unique tracking # would just be a formula field.

I would suggest doing this first in a Copy of your app, if you do not have much experience with change key fields.  Quick Base will maintain all the connections between the Parents and the Children.

Normally the only Fixing that needs to be done after QuickBase makes its changes is on the child forms, the fields for choosing the Parents sometimes needs to be fixed on the form.
Photo of Lee Gilmore

Lee Gilmore

  • 774 Points 500 badge 2x thumb
I just wanted to provide a final update. I did as you suggested and changed the primary key back to the record ID. Your QB Action suggestion worked without the need for a refresh so all goals were accomplished! I really appreciate all the time and effort you spent to help get me to this conclusion. I've learned a lot in the process.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,826 Points 50k badge 2x thumb
Thx for letting me know!