Skip to main content

I have issue with getting details from forms based on a list of forms

List of forms: https://api.goformz.com/v2/formz

Form details: https://api.goformz.com/v2/formz/formId

Both nested query and pagination works seperately, but I struggle to get it work with both of them. I have tried the solution in the linked case below, but I get stuck on the same place as the user in that case:

The query table is running for approximately correct time (which indicates it is reading the correct amount of data), but no data is going into the SQL-table.

The query is this simple: 

SELECT fields,formId FROM REST.Formz_DataPerForm
WHERE Nested_Id IN (SELECT formId FROM REST.formz_WithDateFilter)

Is it possible to get this working? 

 

 RSD list of forms:

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
<api:info title="formz_WithDateFilter" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
<!-- You can modify the name, type, and column size here. -->
<attr name="formId" xs:type="string" readonly="false" other:xPath="/json/formId" />
<input name="rows@next" desc="Identifier for the next page of results. Do not set this value manually." />
</api:info>

<api:set attr="DataModel" value="DOCUMENT" />
<api:set attr="URI" value="https://api.goformz.com/v2/formz?filter=lastUpdatedDate%20ge%202024-11-09" />
<api:set attr="EnablePaging" value="TRUE" />
<api:set attr="pagenumberparam" value="pageNumber" />
<api:set attr="pagesizeparam" value="pageSize" />
<api:set attr="pagesize" value="100" />

<!--https://api.goformz.com/v2/formz?filter=lastUpdatedDate%20ge%202024-11-11&pageNumber=1&pageSize=2-->

<api:set attr="JSONPath" value="$." />

<!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
<api:script method="GET">
<api:set attr="method" value="GET"/>
<api:call op="jsonproviderGet">
<api:push/>
</api:call>
</api:script>

</api:script>

RSD Form details:

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
<api:info title="Formz_DataPerForm" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1" other:queryslicercolumn="nested_id">
<!-- You can modify the name, type, and column size here. -->
<attr name="nested_id" xs:type="string" readonly="false" other:filter="{nested_id}" other:xPath="/json/nested_id" />
<attr name="formId" xs:type="string" readonly="false" other:xPath="/json/formId" />
<attr name="fields" xs:type="string" readonly="false" other:xPath="/json/fields" />
</api:info>

<api:set attr="DataModel" value="DOCUMENT" />
<api:set attr="URI" value="https://api.goformz.com/v2/formz/{nested_id}/" />
<api:match pattern="*nested_id*" type="glob" value=""_query.criteria]">
<api:else>
<api:set attr="URI" value="https://api.goformz.com/v2/formz/d7149786-2263-46d3-bbd8-a174f3890a67" />
</api:else>
</api:match>
<api:set attr="JSONPath" value="$." />

<!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
<api:script method="GET">
<api:set attr="method" value="GET"/>
<api:call op="jsonproviderGet">
<api:push/>
</api:call>
</api:script>

</api:script>

 


Hi ​@jarle 

The default pagination options do not work when you use a nested call unfortunately.

I now see you aren’t doing a nested call but a query slicer.

Do you get an message like this?

 


Hi Thomas,

I tested nested call earlier, but couldn’t get it to work, so I tried the query slicer. I don’t get any error message, when running the query above. I just don’t get any rows.

If it is possible to do manual pagination somehow, that could also be a solution: There is some info about the pagination in the API here: https://developers.goformz.com/reference/pagination


Hi ​@jarle 

Yes, but it requires you to know what the last page is or what the max number of rows is in the endpoint.

It is hard to do a check for empty data otherwise continue operation in RSD files.

I can see that it returns the amount of rows like so.

{ "x-total-count": 737 }

If you can get this value in a call, you can run it in an enum by dividing with the page size.

You also need to use the round() feature to make sure it is a full number, but otherwise it can be used like I explain in the enum section.

Enum+and+page+method


Hi,

I can test the enum method, but is there an example with enum-method and nested data somewhere? X-Total-Count is a response Header. Do you know how to reference a response Header in the xpath?

Anyway query slicer seem to be a little bit more clean option than the enum method. Do you see any specific reason why it doesn’t work? As it gets zero rows, I guess it doesn’t match correctly somehow.


Hi ​@jarle 

I got my files with Query Slicers to work eventually. Essentially you get the message I shared when one of the tables has an issue.

Once both tables worked it also returned a result.

You can mix the pagination in with the query slicer.

This should work.

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
<api:info title="Formz_DataPerForm" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1" other:queryslicercolumn="nested_id">
<!-- You can modify the name, type, and column size here. -->
<attr name="nested_id" xs:type="string" readonly="false" other:filter="{nested_id}" other:xPath="/json/nested_id"/>
<attr name="formId" xs:type="string" readonly="false" other:xPath="/json/formId"/>
<attr name="fields" xs:type="string" readonly="false" other:xPath="/json/fields"/>
</api:info>

<api:set attr="DataModel" value="DOCUMENT"/>
<api:set attr="URI" value="https://api.goformz.com/v2/formz/{nested_id}/"/>
<api:match pattern="*nested_id*" type="glob" value="e_query.criteria]">
<api:else>
<api:set attr="URI" value="https://api.goformz.com/v2/formz/d7149786-2263-46d3-bbd8-a174f3890a67"/>
</api:else>
</api:match>
<api:set attr="EnablePaging" value="TRUE" />
<api:set attr="pagenumberparam" value="pageNumber" />
<api:set attr="pagesizeparam" value="pageSize" />
<api:set attr="pagesize" value="100" />
<api:set attr="JSONPath" value="$."/>

<!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
<api:script method="GET">
<api:set attr="method" value="GET"/>
<api:call op="jsonproviderGet">
<api:push/>
</api:call>
</api:script>
</api:script>

You just need to pair it with a where clause that gives the list of ids needed to iterate over.

SELECT * FROM OREST].TFormz_DataPerForm]
WHERE Rnested_id] IN (SELECT Cid] FROM OREST].TSourceOfId])

In the log you should see it make this call and actually show the generated SQL as

WHERE Rnested_id] IN (1,2,3,4,5)


Ok, so you have added EnablePaging and the parameters to the rsd file with detail data ( REST].]Formz_DataPerForm]).

I still get no data when doing it. When I try to query the eREST].TFormz_DataPerForm] with only one Id, I still get no data:

 


Hi ​@jarle 

Is it possible for me to try it out?


Hi ​@Thomas Lind 

Yes, Should we take a session, or should I send some keys to use with the api?

I have time for a session whenever tomorrow.

Jarle


Hi ​@jarle 

Both, maybe.

If you send me the files, I can try them out and possibly replicate the issue, then we can do a meeting about it depending on what I find.

Do you know my email, you can send it to me on that?


We finally got this to work by using formId (existing field) instead of nested_id (parameter).

SELECT * FROM REST.Formz_DataPerForm
WHERE formId IN (SELECT formId FROM REST.formz_WithDateFilter)

Now it works with pagination and nested query.

Thanks for the help ​@Thomas Lind 


Reply