Webhook to fire for all records in table when a new record is added

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • Answered
  • (Edited)
I have two tables "Claims" and "Damage items". One Claim can have many Damage items so the latter is the child table. Damage items are represented using a Damage code and these codes are imported to Quickbase from an external app. When a claim is added to Claims table, there is a field that has a concatenated string of multiple damage codes. Example A1151, (Just a quick explanation of how the codes work -  A1 is Front Bumper guard, 15 is Scratch and 2 is less than 2cm). This string could have upto 12 damage codes concatenated with the character "-" (eg: A1151-P4052-S3115-and so on). Using the Part function, I've created 12 separate fields (columns) in the Claims table to decode each damage code. Then I've set up a webhook to automatically create a separate child record under Damage items table for every claim that is created using a field called Damage Code.

One of the requirements is for the user to be able to modify the Damage codes in Damage Items records individually where necessary. Since these damage codes are just characters, I've also created a separate lookup table "Damage Codes" and created a relationship with the Damage Items table so the user can easily identify the damage code by a suffix with the actual text-description from a drop down menu. Eg rather than just selecting A1, the list shows as "A1 - Front Bumper guard". This lookup field (lets call it User Input field) also resides within the Damage Items table but is separate to the first Damage code field that is populated by the Webhook which is also in the Damage Items table.

In the Damage Items table, I have created another field (Damage Code Description) to decode the Code to show it as "A1 - Front Bumper guard" like format. Then I've created another Webhook to copy the value of the Damage Code Description and pass it into User Input field with the condition when a new record is added or modified and if the Damage Code is null.

This approach works well when there is only one damage code in the claim. When there are more than one Damage code, the first webhook successfully creates a child record for each damage code in the Damage Items table. But the second webhook only perform the passing of the value in one record. This is most likely due to the webhook is only able to perform an action on one record at a time and not for the other records that have been added at the same time?

Really sorry about the lengthy text, but I'm new to QB and not sure what else to do to fix this issue. Any help would be greatly appreciated!!


Photo of Sini Wickramasinghe

Sini Wickramasinghe

  • 290 Points 250 badge 2x thumb

Posted 3 months ago

  • 0
  • 1
 <records_csv>
      <![CDATA[
%RepeatOn%
[field1],[field2]
%RepeatOff%
]]>
   </records_csv>

You need to use %RepeatOn% and %RepeatOff% as shown above.

Photo of Sini Wickramasinghe

Sini Wickramasinghe

  • 290 Points 250 badge 2x thumb
Thank you Surya, should I try this with API_ImportFromCSV method? I did try with this method and I did not get the outcome I was after....
It works well with the API_ImportFromCSV. When you use the repeat on and off markers, it is especially useful when the user changes data several records at a time, such as in a grid edit or when importing. It works for me all the time. May be you could share the error message or the exact code (hide confidential stuff). Also remember to use the fields ids to update between the <clist> and </clist> tags. To update existing data, you should include the primary key as a part of the incoming fields as well as in the clist set.
Photo of Sini Wickramasinghe

Sini Wickramasinghe

  • 290 Points 250 badge 2x thumb
Thank you for your response Surya! I've actually used this approach for another feature of the app. I had to change the workflow and the app structure to work around this issue I have so didnt have to use a webhook at all. Best wishes!