Pulldata @layer seems to be caching results

789
7
Jump to solution
02-15-2023 01:40 AM
OlivierDemars1
New Contributor III

Hi,

I count the number of records related to a specific task this way:

pulldata("@layer", "getValue", "attributes.totalcount", concat(${url_query}, '?outStatistics=[{"statisticType": "count","onStatisticField": "objectId","outStatisticFieldName": "totalcount"}]'), concat("task_id ='",${task_id},"'"))

where ${url_query} is the feature layer url and ${task_id} the filter value for the task_id attribute.

It works fine but it seems that Survey123 is caching the result of the request which means that when I create another record related to the same task, the count is not updated.

I was able to confirm that by looking at the requests done by Survey123 with a tool like Fiddler.

This is really annoying for our workflow as it means that Survey123 has to be stopped and restarted for the request to be sent and the count updated.

Could this behaviour be changed?

Thanks,

Olivier

0 Kudos
1 Solution

Accepted Solutions
MobiusSnake
MVP

Maybe try adding a cache buster parameter to the URL?  Something like "xyz=1234567890" where the number is randomly generated?

View solution in original post

7 Replies
MobiusSnake
MVP

Maybe try adding a cache buster parameter to the URL?  Something like "xyz=1234567890" where the number is randomly generated?

OlivierDemars1
New Contributor III

Great idea, it works, thanks. 

I just changed my call like this:

pulldata("@layer", "getValue", "attributes.totalcount", concat(${url_query}, '?outStatistics=[{"statisticType": "count","onStatisticField": "objectId","outStatisticFieldName": "totalcount"}]'), concat("task_id ='",${task_id},"' and task_id <>'",string(random()),"'"))

0 Kudos
DustinHorn2
New Contributor II

I have ran into the same issue, but I am using getRecord instead of getValue. I have a field (form_json) to store the json with it's calculation looking like this: 

pulldata("@layer", "getRecord", "<PortalURL>?orderByFields=readingtime2 DESC", "1=1")

I then use pulldata again to populate the field I want with:

pulldata("@json",${form_json},"attributes.hscurrentmeterread")

I'm unsure how to use the random function as you did above to make my call refresh every time.

0 Kudos
DustinHorn2
New Contributor II

I was finally able to get it. Needed to remove 1=1 

0 Kudos
DavidRedondo
New Contributor

Hey guys, this is a really useful topic, I am trying to get the count of concrete selection on a field, and that's working well, but when I try to combine with other field to get the data filtered by both fileds it shows nothing...

 

pulldata("@layer", "getValue", "attributes.totalcount", concat(${URL}, '?outStatistics=[{"statisticType": "count","onStatisticField": "objectId","outStatisticFieldName": "totalcount"}]'), concat("lugar ='",'Casco Antiguo',"' and fecha_de_la_Recogida ='",${fecha_de_la_Recogida},"'"))

 

Ok, I just managed to see that the URL for the first field was in the general table (/0) and the last one in the repeat (/1), so I made another line:

 

pulldata("@layer", "getValue", "attributes.totalcount", concat(${URL2}, '?outStatistics=[{"statisticType": "count","onStatisticField": "objectId","outStatisticFieldName": "totalcount"}]'), concat("fecha_de_la_Recogida ='",${fecha_de_la_Recogida},"'"))

 

But even with this alone I cannot get any result 😞

 

Anyone can help me to figure this out? Thanks in advance!!

0 Kudos
DavidRedondo
New Contributor

any thoughts? 🙂

0 Kudos
DavidRedondo
New Contributor

ideas? 🙂

0 Kudos