cancel
Showing results for 
Search instead for 
Did you mean: 

Using Document templates - chaning file name during document creation based on a template file

zputnoky
Star Contributor
Star Contributor

Dear All,

Trying to create a set of department wide (or process related) templates to make sure that our docs are unified and we can use Alfresco features as much as possible.

Created a WORD file and uploaded into to ./repository/data dictionary/node templates. Then used the create document from a model option and selected the template.

The problem I have with this function is this: the document is created with the same file name and extension as the one of the template. When the user is modifying the template - updating some of the information, mostly codes - Alfresco creates a new version of the document. The modification is done via Alfresco and MS Office.

However when the user is changing the file name - as he/she should do, Alfresco is creating a new document and keeps the 1st file as well. The user shall go back to the folder, look for the file with the same name as the template and delete it.

Is there a way to change the file name when the file is created from the template? keeping only the formatting and content of the template file

What is the best way if we need to create hundreds of documents?

Thanks alot,

Zsolt Putnoky

8 REPLIES 8

afaust
Legendary Innovator
Legendary Innovator

I don't really understand how your users are changing the file name that results in a new file. Renaming a file will change the name on the original and not create a new file at all. Only if users - for some reason - download the file, rename and then re-upload it will a second file be created.

By default there is no option to automatically rename a file when creating it from a template. But you could set up a folder rule that conditionally renames the file when it has the "copiedFrom" aspect and a "source" document that is contained in the data dictionary - node templates folder. You would have to write a small JavaScript file for this and place it in the data dictionary - scripts folder to be selectable in the "Manage Rules" action where you can set "Execute a script" as an action for new files to be created in a specific folder tree.

zputnoky
Star Contributor
Star Contributor

Hi Axel,

Here is what/how I tried:

  • Created a node template by uploading an MS WORD file with the name of Template.doc
  • In a site/folder I selected: create document based on a model and selected the Template.doc file
  • Alfresco created the document in the folder and called it Template.doc
  • Selected the document and used the Modify in MS Word menu
  • The file opened in MS WORD where I did the modification
  • Then I had to save the file with the proper file name, so I used SAVE AS, selected the folder in Alfresco, created a new name, and saved the document
  • Once Alfresco is refreshed, I got two files. The 1st one is the one with the name of Template.doc, the 2nd one is the file with the proper name

The only method - before your reply - I found is the following:

  • Create the file from the Template.doc
  • Select Edit properties
  • Change the name property to the right one
  • Select the Edit in MS Word option
  • Do the modifications then save the file

This worked so far on the test I did, but I will try now your idea as well.

Regards,

Zsolt Putnoky

afaust
Legendary Innovator
Legendary Innovator

The first approach you tried is absolutely the wrong one to use. You are explicitly creating a new document by using the "Save As" feature in MS Word. The  second approach you described is the correct one to use - rename the file within the Alfresco UI.

The approach using a rule is just an automation / simplification for users, and requires that you have some kind of logic that defines what the new file name should be.

zputnoky
Star Contributor
Star Contributor

Thanks for the confirmation Axel, I will update the user guide as such, then we will see how can I create the file name by concatenating several document properties, that would be even better.

douglascrp
World-Class Innovator
World-Class Innovator

Just to add to the thread, what I have done once was to customize the "Create from template" action and force it to show the edit-metadata form just after the document got created, and by doing so, the users were able to just change the  properties as they wanted.

Hi Douglas,

Can you share what have you done with the Create from Template action to show the property form? I have a new idea to implement: we have a contract folder type. this folder has few custom attributes, two of those are dates, basically close out dates. The idea is the following: when the user creates the folder, he/she has to provide the values for these properties. then Alfresco sends an email to a predefined group of user with the email subject formated to store few of the custom properties. A rule + script at outlook checks the incoming mail and if the sender is Alfresco and the subject is formated a certain way, the rule creates a calendar (or task) item and deletes the mail. the outlook part is okay, made it work, however I have some issues at Alfresco.

My idea is to force the property at upload time and send the mail when the save/create button is hit.

Hope you got what I plan to do, not sure it is clear enough.

I guess your code might be able to help to fire the email.

Thanks alot for your help,

Zsolt Putnoky

douglascrp
World-Class Innovator
World-Class Innovator

Ok, I can share the code with you, but not in the next few days, as I am too busy with other projects.

I will have to dig into the project's code to take that part.

For My idea is to force the property at upload time, you can use the uploader-plus addon GitHub - softwareloop/uploader-plus: An Alfresco uploader that prompts for metadata . It does exactly that.

And following, for and send the mail when the save/create button is hit. I don't think it is a good idea to attach that event into the UI. It would be better to work on the server level, using a folder rule or even behaviours to act when the save is executed.

I guess your code might be able to help to fire the email. Again, my code is not the ideal trigger for this case. Consider the last paragraph information.

Hi Douglas,

I am aware of the Uploader Plus add-on, tested it...but, at config time I should specify the upload folder. In our case, the folders are created ad hoc in various sites as the project is advancing. I am not able to predefine the upload folder in advance. One of the option would be to use a default upload folder, then a rule to distribute the documents into the right folders based on their meta data, but I am not sure this would be acceptable for the users.