I've been working on a Maestro form that has a large amount of attachments that have visibility logic. While testing the form I selected one option that presented one attachment, uploaded a file to it, and then changed the initial option, which hid this first attachment, and presented me with another attachment. I then uploaded to that one, and continued on with submitting the form.
When I received my delivery email I discovered that there were two attachments that came through for the submission. Technically this submission should have only one submission, but both the hidden one, and the one the form was submitted with came through.
Is there a way to delete an attachment from the server if the attachment in question is hidden before submission?
Does Util.hasAttachment() get removed from mastro as we cannot find it in the rule or in the API Util method.
Hiding an attachment field with a visibility rule has no effect on the attachment data. Hiding simply removes it from the display, but the data still remains.
I'd suggest you write code in a validation rule that checks to see if any attachment fields have attachments, and if they are not visible, make them visible again, and display a validation message instructing the user to delete the attachment.
You can use Util.hasAttachment to check if attachments are present in an attachment component. There's a rule helper you can use inside a code editor if you right-click an attachment component in the tree:
Once the attachment is visible again, its uploaded file can be deleted by clicking the attachment's trashcan icon at top right: