Symptoms
How to rename an attachment before uploading, and when deleting an attachment from a form, delete it from the document library as well.
Diagnoses
SharePoint Document Libraries force uniqueness for the 'Name' column. Filename is grayed out in the 'Set a Control's Properties' rule.
Resolution
Documents will need to be uploaded then renamed. This ensures that future uploads are unique, though it will still throw an error if a duplicate document name is submitted, so you may need to clear any existing documents that could conflict.
- Pass back the 'Name' field from the Output Mappings of the Upload Document method to a Parameter
- After the Upload Document method, execute the Document Library SmartObject's 'Rename' method, passing in the name in that parameter and your new unique name (could be something like kParameter]eID] to make it unique)
Regarding deletion:
- On the Edit/Display forms' Get Documents calls that pull in the form's associated attachments, return the Output Mappings 'Name' value to a parameter associated with each attachment
- On each attachment's delete button, use the associated filename parameter (the Delete Document method requires the file extension along with the file's name)