How to get webhook to fire for all records not just the first one to change

  • 0
  • 3
  • Question
  • Updated 2 years ago
  • Answered
I wrote a webhook and tested it by changing a flag field in a number of records (via gridedit). Unfortunately, only the first record was updated, all the rest were ignored. I assume my code is faulty, not repeating for all the changes in all the records?  
1. The Source Table where the webhook resides is a connected CSV table
2. The Destination Table is also Connected CSV (a different source file)
3. I used EditRecord
Photo of Stephen

Stephen

  • 792 Points 500 badge 2x thumb

Posted 2 years ago

  • 0
  • 3
Photo of Stephen

Stephen

  • 792 Points 500 badge 2x thumb
The key field is not Record ID, it is [SOP+SKU] Field. 
The record being updated is fid 127 in the destination table using the value in the [Order Status] field from the source table. 
All this works correctly but for only 1 record at a time. I would have though it would fire on all changes?
I think for this you can use the %RepeatOn% and %RepeatOff% so that it picks up all the records.
You may also have to use API_ImportFromCSV.

Use API_ImportFromCSV to add or update several records. You invoke this call on a table-level dbid. You can add AND update in the same API_ImportFromCSV request. (For an Add, leave the Record ID empty.)
Photo of Stephen

Stephen

  • 792 Points 500 badge 2x thumb
I tried repeat but must have implemented wrong. I'll switch to API_ImportFromCSV and give that a try. Thanks.
Just another quick one.   I don't think you need the Key Field / Record ID in the header as for me that would just indicate a single record. Just thinking :)
Have a look in the API.
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
Michael, I guess that is perhaps where I'm goofing up (Forgive me I'm new to this.)1. If I don't put the Key in there, how does the webhook know which record in the parent table to update? 
2. Shouldn't the webhook fire one time for each record in the source table, rather than 1 time for 1 record and not for the rest?
3. The "repeat" had made sense to me in the case it only fires once, but I wasn't sure how to implement that. I tried it but it did not work (probably because I did it wrong)
4. Is there written documentation somewhere that shows how to do this stuff? I have looked at the PDF API guide, but it talks NOTHIGN about %RepeatOn% and other syntax issues. Perhaps I should be modeling this knowledge on some general language rules outside Quickbase, but I don't know where to look. I can learn it if I can just find the knowledge resource.

Thanks!
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
I suspected that if I didn't the Key field in there it would ADD a record when I just want it to update existing?
(Edited)
In one of the webinars Kirk Trachy discusses webhooks around the 50 minute mark.
You can view it here.  https://quickbase.webex.com/quickbase/onstage/g.php?RCID=0f84c132c8ee5cedca1ce94338ae3a7a

Just click on playback and enter your email etc to view it.
Photo of Ringoparr

Ringoparr

  • 854 Points 500 badge 2x thumb
I'd like to sit in on one of his webinars - where do i sign up to join the club?
http://www.quickbase.com/webinars
There are also recorded webinars.   Very useful :)
Photo of Stephen

Stephen

  • 792 Points 500 badge 2x thumb
Michael, That webcast was so helpful. It showed me I was doing it all wrong and went this route and it worked the first time!
the Key is this: The "repeat" is put around the the top section only because the API is building a CSV table to hold the read data. Then the <clist> section merely writes all the data at once. That was confusing until the host explained that.
Secondly, when the record ID is the one of the fields in the destination clist, it updates and if the record ID isn't there it adds. Very nice!

<qdbapi>
<usertoken>bxxxxxxxxxxxxxx</usertoken>
<records_csv>
<![CDATA[
%RepeatOn%
[new.SOP+SKU.csv],[new.Order Status.csv] <=== FIELDS you want the data from
%Repeatoff%
]]></records_csv>
<clist>6.7</clist>   <=== FIELDS DATA IS GOING TO IN THE TABLE ABOVE (LINK)
</qdbapi>