Conditional statements in an API call with webhooks

  • 0
  • 2
  • Question
  • Updated 3 years ago
  • Answered

I'm familiar with utilizing the API in  URL format, and have had some success translating some of those to XML for use with the new webhooks feature.  However, where i'm stuck now is trying to include conditional statements in these calls beyond what is available in the regular conditional options when setting up the webhook.  

Namely, i'm wondering if it is possible to execute an API_EditRecord that conditionally changes field values based on logic in the message body?

Basically a call that would look like this via URL:

& if([Field 1]<>"", "&_fid_10="&URLEncode([Field A]))
& if([Field 2]<>"","&_fid_11="&URLEncode([Field B]))
& if([Field 3]<>"","&_fid_12="&URLEncode([Field C])

I can't utilize individual webhooks for each statement because I have more than 5 fields that I need to apply conditional logic to independently of each other.

Is this possible within the native webhooks function?   




  

Photo of Drew

Drew

  • 482 Points 250 badge 2x thumb

Posted 3 years ago

  • 0
  • 2
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,332 Points 50k badge 2x thumb
Let's say you have 10 fields to update like this. You could have 10 fields called [New Value Field 1], [New Value Field 2].  The formula there would be the current value of [Field A] ([Field B]) etc if it was not blank, else the new value.

Then the webhook could UNconditionally do the edit, and in many cases it would just edit a field to a value it already was.
Photo of Drew

Drew

  • 482 Points 250 badge 2x thumb
Yes - I do go this route in some instances.  In the case above, what i should have pointed out is that some of the field updates are change tracking - i.e. if the value of [Field A] changes, update [Date A] with the current date, update [User A] with the user, update [Text A] with the new value (which is a field that logs the edits).  So I can't actually have the field update(s) fire unless a change is made.  If this sounds familiar, you helped me solve this problem via a URL API call a few years ago.  I'm just trying to automate the process with this new feature if possible.

https://quickbase-community.intuit.com/questions/796894-conditional-logic-in-formula-url-fields-with-api
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
Here is an idea that you might try (I have not test it myself yet).

From the operation of the "Choose Fields and Markers" option it appears that the selected field or marker is inserted into the Endpoint URL text entry box at the current place of the cursor and that the final URL is just obtained by substituting the fields and markers within the text of the entry box. So if all that is going on is text substitution perhaps you can create a formula text field called [Endpoint URL] and place that single field into the Endpoint URL text entry box. Then in the formula definition for [Endpoint URL] put all your logic (including testing for empty fields) so the formula always returns the correct URL for adding the non-empty values to the new record.

Stated in other words, perhaps you can calculate a text formula field named [Endpoint URL] and place that field alone in the Endpoint URL text entry box.