04-04-2018 02:41 PM
Hello everyone, I am new to Alfresco and I am working on a project in which I have to create a folder where all the stored files are going to be of the same format (word or pdf) and each file must have the same name only differentiated by a number. This number represents the document number and must also be included in the content of the document. Users will create these documents from a template and the document number must be assigned automatically. If you could give me a hand to know where to start or which way to go, will help me a lot.
Thanks in advance
04-05-2018 02:37 AM
Hi,
Maybe a first approach could be something like this:
- Define a content rule on an specific folder
- On create document, this rule will execute a script.
This script return number of documents of the folder and change de name of document to: "samename_returnedvalue"
¿The number of document should be in the text of document or like a property?
Regards,
clv
04-05-2018 07:43 AM
Thanks for your response my friend.
I need to have the document number in the text of the document. It is not necesary to have it as a property.
Do you know any tutorial to help me starting with usign scripts in alfresco?
04-05-2018 09:44 AM
There are three parts to your question.
First, automatically generating a document number. To do that, consider writing a "service" class that is responsible for handing out document numbers. It's up to you whether you store the number in a database or somewhere in the repository. Many people prefer to just write a little JSON document in the Data Dictionary that tracks document numbers.
Next, you want to insert the number into the content of a file. This is tricky because if you are dealing with a variety of binary file formats, you'll potentially need an API for each one. You also need a way to specify where in the file the document number will be placed.
If you could simplify your requirement to a specific file type that would help. For example, if you were to only need to insert the doc number into Word documents, you could use docx4j. I like docx4j because it is easy to do simple things like create a document template that has a placeholder, then send key-values to the API to replace the placeholders with the values. You can place this logic in a general "doc generation" service class.
Last, how you actually trigger the generation and insertion. As Jose mentioned, a rule is probably the best approach here. The rule should probably invoke a Java-based rule action class that leverages the autonumber service and the "doc generation" service mentioned above.
04-05-2018 09:57 AM
Thanks for your response... can you please be a litlle more specific in how to do the "Service" in the first part. Im new in Alfresco.
For the other parts of your response i think i am only going to use word files to avoid the problems you describe.
Explore our Alfresco products with the links below. Use labels to filter content by product module.