Forum Discussion

JackFretwell's avatar
JackFretwell
Qrew Assistant Captain
6 years ago

Example of Message body for API_DoQuery Webhook

Can someone provide an example "Message Body" for an API_DoQuery Webhook, I'm lost on how the fields get populated from the XML reply and I'd like to see the structure of the code. 
  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    I have this so far


    <qdbapi>
    <usertoken>%user.token.XXXXXXX_XXXX_cgmx.Weebhook 001%</usertoken>
    <apptoken>XXXXXXXXXXXXXXXXXXXXX</apptoken>
    <field fid="85"><query>{17.EX.'BEL001@bombouche.com'}</query></field>
    <clist>108</clist>
    <includeRids>1</includeRids>
    <options>num-1.sortorder-A</options>
    </qdbapi>

    This is trying to bring in the company name based on the email address.  Fid 108 is the company name field.  17 is the email address field.

    I'm not sure if this is the correct layout as there seems to be little information out there and the example from the api guide looks off.

    It would be great to see a working example. 
  • So 2 things based on how I'm reading the question and a note on your example

    -In your body - you don't need <field id="85"><query></query></field>
    If you look at the API Docs you'll see that the tag just need to be <query></query>
    https://help.quickbase.com/api-guide/do_query.html

    -When you say webhook - do you mean you're actually trying to send a your query through a Quick Base webhook? If yes - can you explain a little more what the end goal is? Webhooks send requests out - but they don't receive it back in a way you can use. Meaning that if you use a doQuery out - you need a way to actually parse the XML response to be able to act on that information. So even if you get this working - you don't have a way to take any action on it. What is the end goal?

    Chayce Duncan | Technical Lead
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base
  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    Thanks for replying, I've been told now that I can't use DoQuery in a web hook.

    I have a table which is populated via a webhook from our front end system, call this table sales. 

    What I would like to do is bring in our sales people data based on the email address of the company making the request.  We have corresponding email address in our contacts table which can then bring in other fields like sales manager.  This will save people updating these manually which is what our manager is after.  
  • Is this a production app currently? And do you know what the key field in your contacts table currently is? 

    Option 1 - If possible - the ideal solution would be to change the key field of your 'Contacts' table to be the 'Email' field. If done that way - you could automatically relate your contacts your 'Sales' table as you called it - but making the email brought in via your front end system as the reference field. Basically if your contacts were unique by Email - your 'sales' data could auto-relate. However - if this app is in production and your contacts are widely used - this approach should be taken with caution as changing keys late in the game comes with risks. 

    Option 2 - if you have an integration tool like Workato  - you could have a secondary process in that tool to do what I now see you were trying to do with the DoQuery - and have a background process that relates your new 'Sales' to the appropriate person.

    Option 3 - if you're familiar with a development language - you do the same thing as in option 2 - but just script it into a Quick Base code page - and have someone click a button to sync your data via Javascript, or write a background job to do in a server language like Ruby or Node as another option. 

    There is a 4th option - but its very hacky for lack of a better word in this case - and works only in very fringe cases of Quick Base. When you are bringing in data from your front end system - is it being brought in one by one? Or in mass - meaning lots of records at once.

    I'm happy to elaborate on any of the above as well if you want more info.

    Chayce Duncan | Technical Lead
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base
  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    Thank you for the thought put into this.

    Option one is risky as this database has been in production for over a year so I'm reluctant to change the primary key.

    Option two, I've arranged a demo with Workato.

    Option three, I'm writing some Java for a button, but what we want to avoid is any manual intervention which is why we're not looking to use QB relationships as they need someone to click something.
    I'm using the iol technique and API_DoQuery for the Java script but I'll look into Ruby or Node. 

    Option four, we have a webhook to our front end system, the orders come through to us when the client hits submit.  I'd want to keep clear of touching anything here as it all works.

    One thing I'm surprised about Quickbase is that it is so difficult to update one table from another by using a common field which isn't a relationship, it's baffling, any chance you can ask someone to write the equivalent of an SQL UPDATE query or Excel Vlookup? 

    Jack Fretwell
    jfretwell@mailandprint.co.uk

  • A SQL Update Query would be similar to what I was mentioning with Ruby or Node to run a background job for you. Partners like myself can help in that setting - thats also where a tool like Workato can be set to operate the way you first described the original intent. 

    You mentioned IOL - which is another option I forgot about. It will likely work pretty well for you - the only potential gap is that IOL would run when someone loads the form - so there is a lag between when the order is entered and when someone opens it and your script ones. 

    It sounds like you're pretty proficient in JS - so an option outside of a server process would be google scripts. You can code it in JS and set it to run on a schedule - so every 10 minutes, hour or so have it look for any new orders without an assigned contact, loop through each, query for a match, edit your orders

    Chayce Duncan | Technical Lead
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base