Forum Discussion

StephenStephen's avatar
StephenStephen
Qrew Assistant Captain
9 years ago

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

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
  • StephenStephen's avatar
    StephenStephen
    Qrew Assistant Captain
    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?
  • MichaelGraham2's avatar
    MichaelGraham2
    Qrew Assistant Captain
    I think for this you can use the %RepeatOn% and %RepeatOff% so that it picks up all the records.
  • MichaelGraham2's avatar
    MichaelGraham2
    Qrew Assistant Captain
    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.)
  • StephenStephen's avatar
    StephenStephen
    Qrew Assistant Captain
    I tried repeat but must have implemented wrong. I'll switch to API_ImportFromCSV and give that a try. Thanks.
  • MichaelGraham2's avatar
    MichaelGraham2
    Qrew Assistant Captain
    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.
    • StephenStephen's avatar
      StephenStephen
      Qrew Assistant Captain
      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!
    • StephenStephen's avatar
      StephenStephen
      Qrew Assistant Captain
      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?
  • StephenStephen's avatar
    StephenStephen
    Qrew Assistant Captain
    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>