Skip to main content
Version: 8.1

Customize MS Word reports

Level: beginner

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 report - general procedure article (user documentation).

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:

  1. Install the MS Word Report Designer plug-in. This is a one-time procedure. Learn more in the Install Creatio plug-in for MS Word article (user documentation).
  2. Add a new report record in the Report setup section.
  3. Set up the report display parameters
  4. 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.
  5. Set up the report template layout in the Creatio MS Word Report Designer plug-in and upload the template to Creatio.
Structure of macros in MS Word reports
ColumnName[#Macro name|Arguments#]

[#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.

Example
ColumnName[#Date#]

If the entered value is "07/15/2020 11:48:24 AM", the macro will return "15.07.2020".

ColumnName[#Date|MM/dd/yyyy#]

If the entered value is "31/01/2019 08:25:48 AM", the macro will return "01/31/2019".

[#Lower#] macro

Converts the value of a string to lowercase. The macro has no arguments.

Example
ColumnName[#Lower#]

If the entered value is "ExaMpLe", the macro will return "example".

[#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.

Example
ColumnName[#Upper#]

If the entered value is "example", the macro will return "EXAMPLE".

ColumnName[#Upper|FirstChar#]

If the entered value is "example", the macro will return "Example".

[#NumberDigit#] macro

Convert a raw number to a number with digit group separators. The default delimiter is the space character. The argument is optional.

Example
ColumnName[#NumberDigit#]

If the entered value is "345566777888.567", the macro will return "345 566 777 888.567".

ColumnName[#NumberDigit|,#]

If the entered value is "345566777888.567", the macro will return "345,566,777,888.567".

note

If the fractional part of the number equals zero, only the integer part will be returned. If the entered value is "345566777888.000", the macro will return "345,566,777,888".

[#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".
Example
ColumnName[#Boolean|CheckBox#]

If the column contains the true value, the macro will return "".

ColumnName[#Boolean|Yes,No#]

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 report - general procedure article (user documentation).

The general procedure of creating an MS Word report using custom macros is as follows:

  1. Install the MS Word Report Designer plug-in. This is a one-time procedure. Learn more in the Install Creatio plug-in for MS Word article (user documentation).
  2. Add a new report record in the Report setup section.
  3. Set up the report display parameters
  4. Implement custom macros.
  5. Set up the report data fields and tables.
  6. 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:

[ExpressionConverterAttribute("CurrentUser")]

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:

  1. Create a new report in the Report setup section.
  2. Set up the report display parameters.
  3. Set up the report data fields and tables.
  4. Add the Id column to the list of report columns that will be the incoming parameter for the custom macro.
  5. 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.
  6. Publish the Source Code type object schema.
  7. 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.
note

You can view the record Id in the database table even if you do not have access to the database. To do this, display the Id system column in the window of binding data to packages.