Discussions

Expand all | Collapse all

How to build a query string for API_DoQuery when the matching value is a variable

  • 1.  How to build a query string for API_DoQuery when the matching value is a variable

    Posted 08-02-2018 17:04

    Hi Guys,

    I am currently working on a project to integrate ServiceNow with Quickbase. I have a question with regards to building a query when the value to be compared against cannot be hardcoded in quotes but it?s a variable instead. For instance based on the documentation for Quickbase APIs you build a query parameter this way:

    {'fid'.operator.'matching_value'}

    Now let?s say you don?t know what the ?matching_value? above is which means you cannot hard code the actual value but you want to use a value in some variable and that variable can be whatever your logic put in there, the question I then have is how would you build the query string in a use case like that?

    For instance if I build my query string this way:

    r.setQueryParameter('query', "{3.EX.'7635'}");

    I get the desired results because I hard coded the matching value.

    However in my use case for the type of the integration that I am building the user will populate the form with this value and when the record is created in ServiceNow I want to take this value and use it as a matching value when building the query in my integration script. Basically something like this  

    r.setQueryParameter('query', '{3.EX.quickBaseId}');  

    where quickBaseId is the value the user entered when creating the record that I want to integrate with Quickbase. This however does not work.

    Would you guys please advise as to how can I build a query when the matching value is a variable.

    Thanks,

    Johannes


  • 2.  RE: How to build a query string for API_DoQuery when the matching value is a variable

    Posted 08-03-2018 05:22
    Please try this -

    r.setQueryParameter('query', "{3.EX.'"+quickBaseId+"'}");


  • 3.  RE: How to build a query string for API_DoQuery when the matching value is a variable

    Posted 08-03-2018 14:34
    Hi Arpana,

    Thanks for your response. I got some post here in the community where somebody had a similar problem and I followed that post to get my code to work. The solution is exactly similar to what you are suggesting here.

    This is how it looks :

    r.setQueryParameter('query', "{3.EX." + quickBaseId+ "}");

    Once again thanks
    Johannes