Users can create MS Word reports in Creatio and configure them using the Creatio MS Word Report Designer plug-in. Learn more about creating and setting up MS Word reports in the "Set up MS Word reports" article.
Use macros to set up extra data output options for an MS Word report. You can use basic macros and create custom macros.
Basic macros
The general procedure of creating an MS Word report using basic macros is as follows:
- Install the MS Word Report Designer plug-in. This is a one-time procedure. Learn more in the "Installing Creatio plug-in for MS Word" article.
- Add a new report record in the Report setup section.
- Set up the report display parameters
- Set up the report data fields and tables. Add a tag with the name of the macro in the [#MacrosName#] format to the column when setting up column fields.
- Set up the report template layout in the Creatio MS Word Report Designer plug-in and upload the template to Creatio.
The [#Date#] macro
Converts a date to a specified date format. The default date format is "dd.MM.yyyy". If the date format is not specified, the entered date value will be converted to the default format. A detailed description of date formats is available in the Microsoft documentation. The argument is optional.
Examples:
If the entered value is "07/15/2020 11:48:24 AM", the macro will return "15.07.2020".
If the entered value is "31/01/2019 08:25:48 AM", the macro will return "01/31/2019".
The [#Lower#] macro
Converts the value of a string to lowercase. The macro has no arguments.
An example:
If the entered value is "ExaMpLe", the macro will return "example".
The [#Upper#] macro
Converts the value of a string to uppercase. The argument is optional. If the "FirstChar" argument is passed to the macro, only the first character in the string will be converted to uppercase.
Examples:
If the entered value is "example", the macro will return "EXAMPLE".
If the entered value is "example", the macro will return "Example".
The [#NumberDigit#] macro
Convert a raw number to a number with digit group separators. The default delimiter is the space character. The argument is optional.
Examples:
If the entered value is "345566777888.567", the macro will return "345 566 777 888.567".
If the entered value is "345566777888.567", the macro will return "345,566,777,888.567".
The [#Boolean#] macro
Converts a boolean value to a custom representation. The argument is required. The following arguments are available:
- CheckBox – converts the entered value to "☑" or "☐".
- Yes,No – converts the entered value to "Yes" or "No".
Examples:
If the column contains the true value, the macro will return "☑".
If the column contains the true value, the macro will return "Yes".
Custom macros
The Report setup section enables users to create MS Word reports using Creatio tools and configure them using the Creatio MS Word Report Designer plug-in. Learn more about creating and setting up MS Word reports in the "Set up MS Word reports" article.
The general procedure of creating an MS Word report using custom macros is as follows:
- Install the MS Word Report Designer plug-in. This is a one-time procedure. Learn more in the "Installing Creatio plug-in for MS Word" article.
- Add a new report record in the Report setup section.
- Set up the report display parameters
- Implement custom macros.
- Set up the report data fields and tables.
- Set up the report template layout in the Creatio MS Word Report Designer plug-in and upload the template to Creatio.
A macro for setting up an MS Word report is a class implementing the IExpressionConverter interface (see the ExpressionConverterHelper schema of the NUI package).
To make a custom macro callable from the report template, mark the macro with the ExpressionConverterAttribute attribute containing the name of the macro. For example:
The Evaluate(object value, string arguments = "") interface method must be implemented in the class. The method accepts an MS Word report template field value as an argument and returns the string type value that will be inserted instead of this field in the ready MS Word report.
The general procedure of creating a custom MS Word report macro is as follows:
- Create a new report in the Report setup section.
- Set up the report display parameters.
- Set up the report data fields and tables.
- Add the Id column to the list of report columns that will be the incoming parameter for the custom macro.
- Add a schema of the Source Code type with a class implementing the IExpressionConverter interface to the custom package. The class must be marked by the ExpressionConverterAttribute attribute with the name of the macro. Implement the Evaluate(object value, string arguments = "") method in it.
- Publish the Source Code type object schema.
- Add a tag with the name of the custom macro in the [#MacrosName#] format to the Id column when setting up column fields.
Transferring the package to another development environment
To transfer the package with the report to another development environment, go to the Configuration section -> the Data tab and bind the data of the following elements:
- SysModuleReport_ReportName – the report. To bind it, use the report Id from the dbo.SysModuleReport database table.
- SysModuleReportTable_ReportName – the tabular component of the report. To bind it, use the report Id from the dbo.SysModuleReportTable database table.
Case implementation algorithm
1. Create a new report
To do this:
- Open the System Designer by clicking
. In the System setup block, click the Report setup link.
- Click New report –> MS Word.
2. Set up the report display parameters
Set the following values in the parameter setup area (2):
- Report title – "Account Info".
- Section – "Accounts".
- Show in the section list view.
- Show in the section record page.
![scr_PrintForm.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/BasicMacros/scr_PrintForm.png)
![scr_Parameters_example.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/BasicMacros/scr_Parameters_example.png)
3. Set up the report fields
In the Set up report data block of the section working area (5), set up the fields to display in the report. To do this, click and select the Name column in the drop-down Column list. A macro will be added to the column later.
![scr_Column_Name.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/BasicMacros/scr_Column_Name.png)
Click Select.
Using the same method, add the Type and Primary contact columns to the template.
The list of columns after this step is presented below.
![scr_ColumnList.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/BasicMacros/scr_ColumnList.png)
4. Add the macro tag to the column name
Change the Name column property. To do this, take the following steps;
- In the Set up report data block of the section working area (5), double-click the title of the Name column or click
in the column title bar.
- Change the [Name] value of the Title field to [Name[#Upper#]].
Click Save.
The list of columns after adding macro tags is presented below .
![scr_ColumnListWithMacros.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/BasicMacros/scr_ColumnListWithMacros.png)
Click Save.
5. Set up the report template layout and upload the template to Creatio
To set up the template:
-
Open any MS Word file.
-
Click Connect on the Creatio plug-in toolbar.
-
Enter the username and password of the Creatio user. Click
next to the Server field.
-
Click New. Enter the server parameters.
-
Click Select report on the Creatio plug-in toolbar.
-
Select the "Account info" report and click OK.
- Set up the template layout. Learn more about setting up a report template in the "Design report layout via the Creatio MS Word plug-in" article.
After the setup, the report looks as follows: -
Click Save to Creatio to load the report template in Creatio.
As a result, the "Account Info" report will be available in the Accounts section list under Print.
![scr_Print_button.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/BasicMacros/scr_Print_button.png)
The report looks as follows.
![scr_AccountInfo.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/BasicMacros/scr_AccountInfo.png)
Source code
You can download the package with an implementation of the case using the following link.
Case implementation algorithm
1. Create a new report
To do this:
- Open the System Designer by clicking
. In the System setup block, click the Report setup link.
- Click New report —>MS Word.
![scr_ReportSetup_startpage.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_ReportSetup_startpage.png)
2. Set up the report display parameters
Set the following values in the parameter setup area (2):
- Report title – "Account Summary".
- Section – "Accounts”.
- Show in the section list view.
- Show in the section record page.
![scr_PrintForm.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_PrintForm.png)
![scr_Parameters_example.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_Parameters_example.png)
3. Implement custom macros
Go to the [Advanced settings] section –> Configuration –> Custom package –> the Schemas tab. Click Add —> Source Code. Learn more about creating a schema of the Source Code type in the Create the Source code schema" article.
![scr_SourceCode.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_SourceCode.png)
Specify the following parameters for the created object schema:
- Title – "AccountInfoByTypeConverter".
- Name – "UsrAccountInfoByTypeConverter".
![scr_AccountInfoByTypeConverter_settings.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_AccountInfoByTypeConverter_settings.png)
Implement a macro class for receiving additional information depending on the account type. The complete source code of the module is available below:
Populate the localizable strings of the report with the following values:
Name | English (United States) | Russian (Russia) |
---|---|---|
PartnerAdditional | Number of employees {0} persons | Number of employees {0} people |
CustomerAdditional | Annual turnover {0} | Annual revenue {0} |
After making changes, save and publish the schema.
Go to the Advanced settings section –> Configuration –> Custom package –> the Schemas tab. Click Add —> Source Code.
Specify the following parameters for the created object schema:
- Title – "CurrentDateConverter".
- Name – "UsrCurrentDateConverter".
![scr_CurrentDateConverter_settings.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_CurrentDateConverter_settings.png)
Implement a macro class for retrieving the current date. The complete source code of the module is available below:
After making changes, save and publish the schema.
Go to the Advanced settings section –> Configuration –> Custom package –> the Schemas tab. Click Add —> Source Code.
Specify the following parameters for the created object schema:
- Title – "CurrentUserConverter"
- Name – "UsrCurrentUserConverter".
![scr_CurrentUserConverter_settings.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_CurrentUserConverter_settings.png)
Implement a macro class for retrieving the current user. The complete source code of the module is available below:
After making changes, save and publish the schema.
4. Set up the report fields
In the Set up report data block of the section working area (5), set up the fields to display in the report. To do this, click and select the Id column in the drop-down Column list. The current Id column will later be used in the custom macro to retrieve the current date.
![scr_Column_Id.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_Column_Id.png)
Click Select.
Use the same procedure to add Id (the column will later be used in the custom macro for retrieving the current user), Name, Type, Primary contact, and Id (the column will later be used in the custom macro for receiving additional information depending on the account type) to the column template.
The list of columns after this step is presented below.
![scr_ColumnList.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_ColumnList.png)
5. Attach custom macro tags to the column names
Change the property of the Id column of an Account object. To do this, take the following steps:
- In the Set up report data block of the section working area (5), double-click the title of the Id column or click
in the column title bar.
- Change the [Id] value of the Title field to [Id[#CurrentDate#]]. [#CurrentDate#] is a the custom macro tag for retrieving the current date.
Click Save.
Use the same procedure to add more custom macro tags to the names of other Id columns.
-
[#CurrentUser]# – for receiving the current user.
- [#AccountInfoByType#] – for receiving additional information depending on the account type.
The list of columns after adding custom macro tags is presented below.
![scr_ColumnListWithMacros.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_ColumnListWithMacros.png)
Click Save.
6. Set up the report template layout and upload the template to Creatio
To set up the template:
-
Open any MS Word file.
-
Click Connect on the Creatio plug-in toolbar.
-
Enter the username and password of the Creatio user. Click
next to the Server field.
-
Click New. Enter the server parameters.
Click OK. -
Click Select report on the Creatio plug-in toolbar.
-
Select the "Account summary" and click OK.
The report setup window looks as follows: -
Set up the template layout. Learn more about setting up a report template in the "Design report layout via the Creatio MS Word plug-in" article.
After the setup, the report looks as follows:
-
Click Save to Creatio to load the configured report template in Creatio.
As a result, the "Account Summary" report will be available on the contact page under Print.
![scr_Print_button.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_Print_button.png)
A report for accounts of the Customer type looks as follows.
![scr_Report_Customer.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_Report_Customer.png)
A report for accounts of the Partner type looks as follows.
![scr_Report_Partner.png](/sites/default/files/documentation/sdk/ru/BPMonlineWebSDK/Screenshots/CustomMacros/scr_Report_Partner.png)