Discussions

Expand all | Collapse all

Webhook + json issue with multi-record updates

  • 1.  Webhook + json issue with multi-record updates

    Posted 08-09-2019 18:56
    I'm trying to use a webhook to send requests to Microsoft Flow. My webhook works for single record updates, but for multi-record updates it only sends a request for the first changed record.
    This section of the QuickBase help documentation seems to apply to my situation, but I can't figure out where/how to syntactically add the %repeatOn% and %repeatOff% instructions.



    Here is my original message body that works for single record updates but not for multis:
    {
      "newStatus" : "[Implementation Status]",
      "newNote" : "[Status Notes]",
      "QuoteProdID" : "[Id]",
    }

    I tried adding the repeat instructions here, but it is throwing an error:
    {
      "newStatus" : "[%repeatOn%[Implementation Status], %repeatOff%]",
      "newNote" : "[%repeatOn%[Status Notes], %repeatOff%]",
      "QuoteProdID" : "[%repeatOn%[Id], %repeatOff%]",
    }

     Can anyone help me figure out what I'm doing wrong?


  • 2.  RE: Webhook + json issue with multi-record updates

    Posted 12-20-2019 11:52
    Bo,

    I found your post when I was trying to figure this out, and I wanted to share my solution.

    %repeatOn% and %repeatOff% loops through all records that were updated and applies anything between those values. For example:
    // Sample Data:
    // Records = 1, 2, 3
    
    // Input 1
    %repeatOn%"[Record ID#]"%repeatOff%
    
    // Output 1
    "123​"
    
    // Input 2
    %repeatOn%"[Record ID#] and "%repeatOff%
    
    // Output 2
    "1 and 2 and 3​ and "

    If you wanted to send the same JSON object for different records, you could use %repeatOn% and %repeatOff% to build an array of JSON objects:
    // Input
    [
      %repeatOn%{
        "newStatus": "[Implementation Status]", 
        "newNote": "[Status Notes]",
        "QuoteProdID": "[Id]"
      },%repeatOff%
    ]// Output
    [
      {
        newStatus: "Active",
        newNote: "foo",
        QuoteProdID: "1"
      },
      {
        newStatus: "Inactive",
        newNote: "bar",
        QuoteProdID: "2"
      },
    ]

    This would also work for building an array nested inside a JSON object:
    // Input
    {
      "newStatus": "[Implementation Status]", 
      "newNote": "[Status Notes]",
      "QuoteProdID": 
        [%repeatOn%"[Id]",%repeatOff%]
    }// Output
    {
      newStatus: "Active",
      newNote: "foo",
      QuoteProdID:
        [
          1,
          2,
        ]
    }

    I hope this helps!

    Thanks,

    ------------------------------
    Evan Westbrook
    PRIME Developer
    Harder Mechanical Contractors Inc.
    Portland OR
    ------------------------------