You are viewing limited content. For full access, please sign in.

Question

Question

Rename the uploaded file before saving to the repository

asked on June 28, 2022

Is there a way to rename the file uploaded by the submitter to a particular format, for e.g. <Last Name>_Resume? Or atleast being able to display a validation message if the submitter is not adhering to the format.

I know that we can rename the file when it is saved to the repository. But we would like to rename the file while it is being routed through the process.

0 0

Replies

replied on June 28, 2022 Show version history

It sounds like you are referring to the "Save to Repository Service Task" in the LFForms Process Diagram.

When you are configuring that service task, you should see a tab for the form itself, and a tab for each uploaded document that exists on that form.  If you go to the tab for the uploaded document, you'll see a Document Name field.  By default, this will say {/_attachment_name}.  But you can edit that to include additional values or replace it entirely.  There is a field picker on the right to select the fields in your process, and you can also use hard-coded text.  The example in your original post would end up looking something like this:   {/dataset/last_name}_Resume

0 0
replied on June 29, 2022

We do rename the file at the 'Save to Repository' task. But what if we want to send the uploaded file as an attachment to an email before the 'Save to Repository Service Task? If the submitter had uploaded the file with just name, we would like to rename it as <Last Name>_Resume for the attachment.

0 0
replied on June 29, 2022

I don't think this is possible directly with Forms.

The Email Service Task doesn't have an option to rename the file.  You can use Javascript to rename the file on the screen in Forms, but what exists behind the scenes (and what gets emailed) still has the original name.

I think your best bet would be to have a Workflow that is triggered after the form and file have been archived to the repository - either triggered by Forms or by the actual activity in the repository of the file being created.  That Workflow could rename the file and email it.

0 0
replied on June 29, 2022

Workflow option can be done, but then first it has to be saved to the repository.

If there is a way to use Javascript to rename the file on upload, I would like to know. Or being able to provide a validation message if the uploaded file name does not match with the naming format indicated.

0 0
replied on June 29, 2022

I tried to get it to work with Javascript - it works on the screen in the form - but then the emailed form still showed up with the original name.

The thing is, these files are being loaded into database (I believe there is an alternate configuration option as well, but I think the default is the database).

Unless I'm mistaken (and I'm kind of guessing here), the file is being loaded into that storage place with the original name regardless of what the form itself thinks - so to change it, you'd need to change it there.

Speaking theoretically, you could have a Workflow edit the database to rename the file after submission of the user task but before the processing of the email task.  However, that means you are making updates to the LFForms database, and that is a very risky thing to do, and I do not recommend it!

You're going to be much better off doing it from the repository and workflow after the process has been archived to the repository.  One idea... You could have your form archive to the repository into a working folder early in your Forms process.  Workflow monitors that folder, does the emailing, and then deletes the stuff from that folder.  Then later your Forms process does the actual permanent archival of your form to the final location in your repository later on.  There's no reason you can't have multiple "Save to Repository Service Tasks" in your process...

To answer your other question about a validation message - yes that is possible via Javascript.  After the upload, you would check the file name(s) and if they didn't match you could warn the user and/or set-up a custom parsley validation.  However, that's after the upload is done.  You can't get the upload dialog prompt to encourage the correct file name (only file types), so you are reacting to the user's actions rather than helping them get it correct in the first place - kind of less than ideal.  Personally, I think having the Workflow do it is better for your users...

1 0
replied on June 29, 2022

Thank you for the immediate & detailed feedback! No plans to touch the LFForms database.

Saving to the repository & then using a workflow  will work to rename the file & then send as an attachment in an email. But it will still have the name of the uploaded file through out the routing process.

1 0
replied on June 29, 2022

Yes, the form will remain inside Forms through the whole process with whatever name was included with the upload.

2 0
replied on April 3, 2023

I tried this but the document is saving as the old name and not the new name placed in the document field name. Is there anything I could be overlooking? I copied and paste the new document in an email to see if that was the issue but the email reflects the document's original name.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.