Select to view content in your preferred language

Survey 123 Pull Repeat data to Report Template

11045
14
05-09-2019 04:18 PM
MatthewYuen
New Contributor

Hi,

I want to pull specific data out of the repeat option for the word template, but it looks like it pulls every row at the moment.

For example, if have 3 repeats, it will pull photo description for all 3 loop.

${#Photograph}

${photo_description}

${/Photograph}

Lets say each description has a value, and the value is test1, test2, test3

In this case, if I used the command above, I would get this as return

test1

test2

test3

What I want is to only pull the value of test 2.  I want to be able to pull specific data I wanted on a specific loop.  No calculation, just values.

What I have right now is a bunch of photo and photo description in a repeat, and I want to be able to pull the pictures 1 at a time so I can setup the word template neatly.  Does that make sense?  Not sure if this is possible with survey123 template management at the moment.

Thanks,

Matthew

Tags (1)
0 Kudos
14 Replies
LiudmilaMaslova
Emerging Contributor

Hello, James
How would I pull specific repeat out of my printed responses? Because right now, it pulls every row to the form. Is there any conditional statement I can use to show one repeat or the other? I have used ${if select_one yes_no | selected:"Yes"} or ${if select_one yes_no | selected:"No"} finishing repeat with ${/}to try to separate both repeats, did not work.

Thank you

0 Kudos
JenniferK
Emerging Contributor

Hi Liudmila,

I ended up figuring it out for my survey thus:

${#repeat_name}$${/repeat_name}

Hopefully that helps you, too!

-Jennifer

Tiff
by
Frequent Contributor

Hi @JamesTedrick, is there something similar for only obtaining the most recent repeat and generating a report? Say, for inspections that are done periodically, our use case is when our team conducts inspections, an email notification is generated for that one repeat record and sent to those who manage the asset. Right now as others stated, we would not want all repeats to be put into one report, and don't want to accidentally send out the wrong one either.

In addition, what makes it more complicated is that we don't only have one photo question, we have a dozen photo questions and respective questions to assess violations/compliance/guidelines etc. It will likely be a fairly long report for just one related record.

Please let me know if you have any suggestions!

Raul
by
Regular Contributor

I think I've found a solution to the OP. This took me a while because I wanted to display ONLY the last repeat and not the nth repeat collected.

For  my solution, I'm keeping track of how many repeat records are being collected in survey123, my sheet looks something like this:

typenamelabel...calculationbind::esri:fieldTypebind::esri:parametersbind::type
        
......Other fields in main FeatureClass     
        
begin repeatmy_repeatMy Repeat I   query allowAdds=true 
imagemy_repeat_imageImage relevant to this collection     
textcomment_my_repeatComments     
end repeat       
        
calculaterepeat_counttotal_repeat_count count(${my_repeat})esriFieldTypeIntegercalculationMode=alwaysint


query AllowAdds=true was used because this repeat is accessed via inbox, this prevents users from deleting previous collections in the repeat. You may nod need it if you're not using an inbox.


Then for my report template I used something like:

 

 

${#my_repeat}
${if ($feature|getValue:"position") == $layers[idx].repeat_count}
${my_repeat_image | size:200:200}
${comment_my_repeat}
${/}
${/my_repeat}

// Where idx is the index of the main layer, usually 0.

 

 

 
In OPs case, tracking the last submitted repeat record isn't even required, you could do something like:

 

 

${#my_repeat}
${if ($feature|getValue:"position") == 2}
// Display the fields you want
${/}
${/my_repeat}

 

 

AnthonyJonesRSK
Frequent Contributor

Hi Raul, I just wanted to say a big thanks for posting your solution, it was a life saver for me for an issue that I raised on the forums a couple of years ago. In my case I was trying to filter my repeats to the latest one using the orderByFields option on my objectid or creation date fields and then limiting it to one record using resultRecordCount. Unfortunately, the orderByFields seemed to cause an error so your workaround of counting the repeats in a field in the form and then using that in an if statement has worked a treat. Cheers

0 Kudos