Document generator
Document Generator compiles the files with .docx-extention, based on the template, created by the user, and by sourcing data from CRM.
-
Rating
-
Installations582
-
DeveloperM. C. Art
Document Generator compiles the files with .docx extention, based on the template, created by the user, and by sourcing data from Bitrix24 CRM.
Quick solution for the template question.Many Bitrix24 clients use the Business Process Designer in their daily work. Business process templates have made work much easier, but manually compiling the same files after working out the business process still delays the execution of the task. For example, such standard documents as a commercial quotation or a contract had to be filled manually with duplicate data — company names, employee names, requisites, etc.
Target
It was necessary to develop a solution that allows to automate the creation of template files by substituting data from business processes. When creating a document, which contains, for example, company data, you have to fill in a lot of fields — name, details, etc. Doing this manually each time takes a long time, and there is a high probability of making an error when copying the data. Therefore, we needed a solution that allows you to transfer data directly from the CRM to the final file.
Result
As a result, we have developed a new activity for the Business Process Designer — "Document Generator", which generates a file with the .docx extension based on the template, created by the user, and sample data like details, names inserted into the template fields after launch of business process.
Principle of operation (example)
To work with the Generator, you have to create a template file with the .docx extension (Please do not use spaces in the file name. Correct example: "Document_Generator"). A template may contain any text with the formatting you need, and it must also contain Merge Field-type fields with specified variable names for data substitution.
You can add fields of Merge Field type this way: click the Ins ert tab, select Quick Parts - Field. Sel ect the «MergeField» type, enter the name of the variable in the «Field name» field, specify the field «Format» as «No».
Save the template.
Attention! When working with MacOS it's desirable to use MS Word for Windows to create templates.
Note the ID field next to the loaded template. It will be used in the Generator settings. If the ID column is hidden, enable it in the settings.
Also create a folder to save the result file after running the Document Generator, and remember its ID.
After downloading the template, you can proceed to work with business processes. For example, we will create a template business process for the company in CRM.
At any point in the business process chain, add the Document Generator (from the Application Actions tab).
Open the Generator settings. The fields are specified in the settings; the data from these fields will be substituted into the variables of the template fields.
Let's look at the settings fields:
• Title — the name of this activity. This is especially convenient if there are several Generator activities in the chain of the business process. In this case, the created files with the result will have different names that you set in the settings of each activity;
• ID of the template (integer) — ID of the file with .docx extention, which was downloaded as a template file in the system;
• ID of the folder — ID of the folder to save the resulting file (integer);
• Name of file — format of the resulting file, for example: KP_{=System:Date} — in this case, the name of the file will contain letters KP, underscore and the current date (if the file with this name already exists, the result will not be saved);
• Label — name of the variable in the template file. If there are several fields of the Merge Field type, click Add button and fill in the names of other variables;
• Text for label — the name of field, from which the data will be taken for substitution. If you have specified several labels, you have to specify the “Text for label” field for each of them. You can choose the data field for substitution from the list - click on the button with three dots.
• Run as - specifies, on behalf of which users to run the business process.
After filling out all the Generator fields click the "Save" button. Then, save the implemented changes into the business process (button below).
Starting a business process
After you have determined all the settings for the Generator, you have to start the business process, with which the file generation will be linked. In our example, the business process is performed on company data, so we sel ect any company from the list and launch our business process for it.
After running the business process, the resulting file can be easily downloaded fr om the folder you specified in the settings, printed or sent by e-mail.
The resulting file completely saves the formatting you specified.
Conclusion
Significantly reduced time of drawing up documents! Also, the human factor is excluded, since it is easy to make a mistake when filling out a multitude of similar documents. And when data is taken automatically fr om the system, such factor is excluded.
M. C. Art knows how to make your work more effective!
Questions and answers
Question:
How to display the ID of the created file, links to view and to download it?
Answer:
Now the Document Generator for cloud Bitrix24 has a new possibility - to output the ID of the resulting file and links for viewing and downloading it. To do this, select the appropriate fields in the "Additional Results" section.
To use this new feature, reinstall the application.
To display the right values of this fields, in the settings of Generator specify "Set status message" - "Yes".
Question:
Can I view the link to the saved file with the result?
Answer:Yes, now the Document Generator has output
parameters "Link to view document" and "Link for
downloading".
Question:
How to display a variable of the “List” type? How to display a variable of the “List” type with multiple choice if more than one val ue is selected?
Answer:
{= Variable: the code of your variable> printable}
or so:
{= Variable: the code of your variable_printable}