Select to view content in your preferred language

Creating reports for most recent repeat (related record)

1036
3
04-28-2023 06:58 AM
Tiff
by
Frequent Contributor

I am working on creating a Survey123 for staff to conduct inspections on assets on a biweekly basis. There are dozens of questions (with images) for each inspection. There is an email field for whoever is responsible for maintaining that asset, which ideally will be used to send out an automated feature report to that email after each inspection.

Feature reports seem to include ALL repeats related to that feature, but I would like to generate a report for only the most recent repeat. We would not want all repeats to be put into one report, and don't want to accidentally send out the wrong one either. It will likely be a fairly long report for just one record as well. 

Is this workflow possible? Are there ways the survey and/or feature template need to be set up to achieve this?

Note: I believe I saw some resources or other posts on how to sort the records such as by alphabetic order i.e., by state or creating an index field for records to obtain the first one, but not sure if that would apply here. We do have a date inspected field (in the related table).

0 Kudos
3 Replies
IsmaelChivite
Esri Notable Contributor

Use the resultRecordCount parameter to get only one record from your table. resultRecordCount combined with orderByFields, will let you get the most recent. For example:

${#myRepeat | orderByFields:"inspectionDate DESC" | resultRecordCount:1}...${/}

0 Kudos
Tiff
by
Frequent Contributor

Thank you very much @IsmaelChivite - I have tried this out and seems to be working well when previewing sample report. I will have to test it in the next couple months with Power Automate.

Wondering if you can answer this offshoot question about feature report design. I am using if statements where if it is not filled in, it does not appear. However, with many questions this could result in a lot of blank space. Can I instead format it so if it exists, include the value, if not, print "N/A"? That way the report would look a lot cleaner and provide clarity. I looked through forums/the quick reference but wasn't able to find the syntax. Thank you in advance!

Edit: I finally had a chance to watch the feature report recording and it was VERY helpful. I see one possible solution for my question above, which is having the general question Yes/No then you can conditionally only show where it = Yes. However, this would result in 10+ more fields so is not ideal. If I could have the conditional question set to identify if no option is selected, that would be really helpful functionality.

0 Kudos
LocationDataServ
Occasional Contributor

Is it possible to do this for multiple records?  I'm in a similar situation where I have a lot of features with multiple inspections.  I'd like to generate repeating rows in a report for the selected features but only show the most recent inspection for each one.  When I added this syntax to the report, I lost the ability to choose between Split and Merge, and now my report is only returning 1 row vs. 4.