Select to view content in your preferred language

Survey with optional attachments automatically creates related record in table even if there isn't an attachment

568
8
03-05-2026 12:45 PM
AnninaRupe1
Frequent Contributor

I have created a survey with Survey123 Connect with the option of adding multiple attachments; I've used a begin repeat with only one record in the repeat, which is of 'file' type. There is only one other parameter for the question: it's required to add an attachment if a previous question is marked as 'yes'. It works great.

However, I have noticed that if a user doesn't need to include an attachment, a relationship record is still created in the related table. This isn't consistent, either; sometimes the relationship record is created and other times it isn't.

The problem comes when users are reviewing the collected data in a web map. The parent record's pop-up states that there is an attachment/related record, but when they click on it, there's nothing attached. I'd like to have a relationship only created when there is actually an attachment. So, if there isn't an attachment, the related record section in the parent record's pop-up would say '0' rather than '1'.

Does anyone know a solution for this?

0 Kudos
8 Replies
MobiusSnake
MVP Regular Contributor

I've seen this behaviour in surveys without attachments as well.  I've seen it the most where there's a parent-child-grandchild relationship - that is, main form, repeat, nested repeat.  Have seen it very inconsistently as well; it usually doesn't happen, but maybe once every 15 or 20 submissions we'll see an empty record that has no values on the required fields.

The only solution I've found (and this isn't great) is to detect these empty records and delete them.  Many of the surveys I work with use a scheduled notebook to perform validation, notification to users, etc., so I've extended this notebook to check for these empty records and delete them when found.  It looks at the repeat tables and checks whether a combination of required fields are all null, if they are then it adds the Object ID to a list and when finished checking all new submissions, deletes those records in a single call.

0 Kudos
AnninaRupe1
Frequent Contributor

Thanks for the insight, @MobiusSnake. I've also been manually deleting the empty records, mainly when I'm migrating my data to new versions of my Tool. Not ideal, but I'm glad to know I'm not the only one in this boat. 

0 Kudos
Neal_t_k
MVP Regular Contributor

Just throwing this out there, have you tried making the image question relevant on something or the whole repeat relevant so it only shows when the user is required to make an attachment.  Worth a shot to see if that prevents it.

0 Kudos
AnninaRupe1
Frequent Contributor

Nice thought, but the user still needs the option to add attachments even if the question that makes adding an attachment required isn't marked as 'yes'. 

A little more background: there is a possibility that a user already has a shapefile available for a site, and instead of having them digitize the polygon again in the survey, I'm having them just do a simple shape over the site. Then, later in the survey, they mark the question "Is there existing geometry available?" as 'Yes'. This then makes the attachment question required, mainly so they don't forget to add the existing geometry. Sometimes, though, the user doesn't have existing geometry so they digitize the site in the survey and they mark the question "Is there existing geometry available?" as 'No'. The attachment section isn't marked as required but it's still visible in case they have site photos they want to keep with the survey.

0 Kudos
Neal_t_k
MVP Regular Contributor

@AnninaRupe1 Thanks for the clarification.  So for context, if a repeat is relevant there is going to be a  related record i.e. if you put '5' in repeat count, you would start with 5 repeats, if they were empty there would still be 5 empty records.  

So how could you achieve you goals:  Make the repeat relevant on a question like. "Add an Attachement" with only yes as an option, default to blank.  Make that question conditionally required from your other criteria.  That way if they are required to have an attachment they have to check "yes", but if not it is an option. Then make the attachment required.  Hope that makes sense. 

0 Kudos
AnninaRupe1
Frequent Contributor

I don't think that will work because if I put a relevant on the repeat, it will only show if the previous question is marked as 'Yes' (there is only one option for this question: 'Yes'. It can be skipped). I still need the user to be able to attach files if that field is skipped.

0 Kudos
Neal_t_k
MVP Regular Contributor

@AnninaRupe1 Correct, it would require user interaction to check that yes button. But you want the option available for them to provide an attachment when not required. That option would be controlled by the user selecting yes and it would be required for them to check use when existing geometry is available.  I have attached an example as maybe I am not explaining it well. 

0 Kudos
AnninaRupe1
Frequent Contributor

I see. Thanks for the example. Unfortunately this makes the survey longer (I know, just one easy question) but users push back on extra questions, no matter how easy. I'll have to just remove empty records every once in a while.

0 Kudos