I am using the 2021.9 version and I have an issue with using the workflow step “Create file…”. I would like to generate a PDF file with a summary for my customer and allow my user to download it. I have gathered the data and used the “Render template” function. As the result of this function, I am getting the report (RenderedDocument) variable. As a next step, I am trying to use the “Create file…” function. Those are my input parameters:
content* (Reader) report.document (output variable from the “Render template”)
resource* (ComposeRecord) record (the workflow will be started on the record details page)
I am also defining a name for the output variable (attachment).
I am getting an error: “not allowed to create empty attachments”
I have no idea why this error occurs (I have used prompted to verify the report.document variable is not empty)
I am unable to locate any documentation regarding using the Attachment:
how to add it to the record?
do I need any special field within the record where any link to the attachment is held?
Use the compose record maker function to prepare a record (you can use record lookup or other functions that give access to a record).
Make sure that the record has a field of type File upload.
Create an attachment
The raw file needs to be converted to an attachment – Create a file and attach it to a resource function.
Here is where the issue lies – you can’t use the reader (internals expect a ReadSeeker, but the workflow passes in a Reader).
Instead of Reader select the String type. The result will be the same but it does need to do some extra pointless steps under the hood (the handler converts the provided Reader to a String and then back to a ReadSeeker.
There shouldn’t be much of a performance impact unless you’re working with giant documents.
Important make sure to provide the file extension with the file name – welcome_message.pdf from my example.
Is this still the method for creating PDF files and attaching them to a record? I followed this pattern but keep getting an “unknown field” error for my file attachment field name. I’m running 2023.9.4. Any help appreciated.
Last question on this topic (hopefully): I would like to delete the attachment before generating a new one. For the attachment (ID) argument in the Delete Attachment function, do I just use the field name (in this case, record.values.credserviceTnsg22File), and are there any other steps I need to take? If possible, I don’t want to leave an orphaned file on the server.