Is it possible to pull data from the most recently submitted survey?

776
4
Jump to solution
08-13-2020 12:32 PM
KateBerg2
New Contributor III

I have a box in my survey for sample numbers and I'd love to prepopulate it with a calculation. The sample number is always X+1, where X is the previously collected sample number. Is it possible to pull data from the most recently submitted survey so I can get this X? 

Thanks!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Philip-Wilson
Esri Notable Contributor

Hi Kate,

No, it is not possible to query data locally on the device from a previously submitted record.

However, you could use a custom JavaScript function and the pulldata @ JavaScript feature to query the feature layer and return the last submitted value for the sample number field. This would require the user and device to be online and have access to the feature layer, and only work when the previous record has already been submitted (ie not in the Drafts or Outbox).

Check out JavaScript functions in survey forms—ArcGIS Survey123 | Documentation and https://community.esri.com/groups/survey123/blog/2020/08/07/extending-survey123-smart-forms-with-cus... for more information.

Otherwise check out this blog post which relates to auto-incrementing "ticket numbers" which sounds similar to what you are wanting to do https://community.esri.com/groups/survey123/blog/2017/11/25/creating-ticket-numbers-in-survey123-for....

Regards,

Phil.

View solution in original post

4 Replies
Philip-Wilson
Esri Notable Contributor

Hi Kate,

No, it is not possible to query data locally on the device from a previously submitted record.

However, you could use a custom JavaScript function and the pulldata @ JavaScript feature to query the feature layer and return the last submitted value for the sample number field. This would require the user and device to be online and have access to the feature layer, and only work when the previous record has already been submitted (ie not in the Drafts or Outbox).

Check out JavaScript functions in survey forms—ArcGIS Survey123 | Documentation and https://community.esri.com/groups/survey123/blog/2020/08/07/extending-survey123-smart-forms-with-cus... for more information.

Otherwise check out this blog post which relates to auto-incrementing "ticket numbers" which sounds similar to what you are wanting to do https://community.esri.com/groups/survey123/blog/2017/11/25/creating-ticket-numbers-in-survey123-for....

Regards,

Phil.

AnaDeniston
New Contributor II

From what I understood Philip, I would be able to use java to get the last record inside a repeat. These links do not include the last record submitted to the survey. 
Is there anything that I am missing?

0 Kudos
Philip-Wilson
Esri Notable Contributor

Hi @AnaDeniston,

As mentioned in chat, the only way you can get a value from a previous record if after it is submitted and hosted int he feature layer, if you know the ID or a way to look it up. There are some other options you could try:

Here is a blog to search() appearance: Dynamic Choice Lists using Search Appearance - Esri Community

Also here is the doc for Linked Content: https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformessentials.htm#ESRI_SECTION1_34A4D...

Otherwise the best option is still to use a JS function.

Regards,

Phil.

AnaDeniston
New Contributor II

Heey Kate, 

Were you able to figure out how to do this? I am running into the same issue.

Thanks

0 Kudos