Setting up the report with an image
Glossary Item Box
Case description
You can set up custom reports using Creatio version 7.15.3 and up.
Create an "Account Info” report that would display the following information about the accounts:
- [Name].
- [Logo].
Source code
You can download the package with an implementation of the case using the following link.
Case implementation algorithm
1. Set up the report display parameters
Set the following values (Fig. 2) in the parameter setup area:
- [Report title] – "Account Info”.
- [Section] – "Accounts”.
- [Show in section].
- [Show in card].
- [Show in the section analytics view].
- [Filter page] – SimpleReportFilterPage.
SimpleReportFilterPage – a client schema that implements standard simple filters.
Fig. 1. – The report setup page
Fig. 2. – Setting up the report display parameters
2. Specify the data sources
In the [Specify data sources for the report] block of the working area (Fig. 1, 4), add the code below:
{ // The name of the data provider class. "ProviderName": "AccountInfoProvider", "Schemas": { "Data": { "Name": { "DataValueType": 1 }, "Logo": { "DataValueType": 14 } }, // Added for localization. "LocalizableStrings": { "ReportTitle": {"DataValueType": 1}, "NameLabel": {"DataValueType": 1}, "LogoLabel": {"DataValueType": 1} } } }
Click [Apply] to save and apply the changes (Fig. 1, 1).
3. Create the report data provider
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 “Creating the [Source code] schema” article.
Specify the following parameters for the created object schema (Fig. 3):
- [Title] – "Account Info".
- [Name] – "UsrAccountInfoSourceCode".
Fig. 3. – Setting up the [Source Code] type object schema
The complete source code of the module is available below:
namespace Terrasoft.Configuration { using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Terrasoft.Common; using Terrasoft.Configuration.Reporting.FastReport; using Terrasoft.Core; using Terrasoft.Core.Entities; using Terrasoft.Core.Factories; // The name of the data provider class for the report, whose logic needs to be implemented. [DefaultBinding(typeof(IFastReportDataSourceDataProvider), Name = "AccountInfoProvider")] public class AccountInfoProvider : IFastReportDataSourceDataProvider { // The name of the schema with the source code. private readonly string _resourceManagerName = "UsrAccountInfoSourceCode"; private readonly string[] _localizableStringNames = new[] { "ReportTitle", "NameLabel", "LogoLabel" }; // Populating columns in the report. private IEnumerable<IReadOnlyDictionary<string, object>> GetData(UserConnection userConnection, IEntitySchemaQueryFilterItem filter) { var esq = new EntitySchemaQuery(userConnection.EntitySchemaManager, "Account"); // Adding columns to the request. var nameColumn = esq.AddColumn("Name").OrderByDesc(); var logoColumn = esq.AddColumn("AccountLogo.Data"); // Adding the created filter. esq.Filters.Add(filter); return esq.GetEntityCollection(userConnection) .Select(x => new Dictionary<string, object> { ["Name"] = x.GetTypedColumnValue<string>(nameColumn.Name), ["Logo"] = x.GetStreamValue(logoColumn.Name)?.ToArray() }); } // Localization of the report title. private IEnumerable<IReadOnlyDictionary<string, object>> GetLocalizableStrings(UserConnection userConnection) { var localizableStrings = _localizableStringNames.ToDictionary( x => x, x => (object)(new LocalizableString(userConnection.ResourceStorage, _resourceManagerName, $"LocalizableStrings.{x}.Value")).Value); return new[] { localizableStrings }; } // Adding the interface filters. private IEntitySchemaQueryFilterItem ExtractFilterFromParameters(UserConnection userConnection, IReadOnlyDictionary<string, object> parameters) { return parameters.ExtractEsqFilterFromReportParameters(userConnection, "Account") ?? throw new Exception(); } // Receive data. public Task<ReportDataDictionary> GetData(UserConnection userConnection, IReadOnlyDictionary<string, object> parameters) { var filter = ExtractFilterFromParameters(userConnection, parameters); var result = new ReportDataDictionary { // Populate columns in the report. ["Data"] = GetData(userConnection, filter), ["LocalizableStrings"] = GetLocalizableStrings(userConnection) }; return Task.FromResult(result); } } }
Populate the localizable strings of the report with the following values (table 1):
Table 1. Setting up the localizable strings
Name | English (United States) |
---|---|
ReportTitle | Account Info |
NameLabel | Name |
LogoLabel | Logo |
Learn more about working with localizable strings in the "Source code designer” article.
Publish the schema.
4. Download the template and set up its layout in FastReport
Download the AccountInfo.frx file. Click [Download file] in the [Download file with data sources to design a report in the FastReport Designer] block (Fig. 1, 4) of the working area.
To open the template in the Report Designer:
-
Run the Terrasoft.Reporting.FastReport.Designer.exe file from the zip archive (Fig. 4) and open the FastReport designer.
Fig. 4. – The FastReport Designer file
-
Click [Open...] in the window that pops up (Fig. 5).
Fig. 5. – The [Open...] button
You can also open the report template from the [File] menu -> [Open...] (Fig. 6) or by pressing [Ctrl+O] key combination.Fig. 6. – The [File] menu with the [Open...] option
-
Navigate to the folder containing the downloaded report (usually, it is the “Downloads” folder), select the file with the template and click [Open] (Fig. 7).
Fig. 7. – Opening the report template in FastReport
Set up the template layout (Fig. 8).
Fig. 8. – Setting up template layout in the FastReport Designer
To display an image in the [Logo] column of the report, select Picture in the [BindableControl] field (Fig. 8) of the report designer when setting up the template.
5. Upload the configured report template to Creatio
To upload the AccountInfo.frx file, click [Upload template] in the [Import a file with the report template] block of the section working area (Fig. 1, 4). Confirm that the template has been uploaded successfully.
As a result, the "Account Info” report will be available on the contact page under [Print] (Fig. 9).
Fig. 9. – Displaying the "Account Info” report on a record page of the [Accounts] section
You can also find the report in the [Accounts] section dashboard view under [Reports] (Fig. 10).
Fig. 10. – Displaying the "Account Info” report in the dashboards of the [Accounts] section
The report is generated as per the selected [Filtered records in list] option on the filtering page (Fig. 11). To upload the report, click [Create report]. To close the filtering page and cancel generating the report, click [Cancel].
Fig. 11. – The filtering page of the "Account Info” report
The report looks as follows (Fig. 12):
Fig. 12. – Example of the "Account Info” report
Report by several records in a section
To receive the report with several records:
- Enable the [Show in section] (Fig. 2) checkbox and select several records in the section list.
- You can use the section filters or the filtering page (Fig. 11) with the [Show in the section analytics view] checkbox selected (Fig. 2, 2).
To include information from several section records in your report (Fig. 13):
- Open the needed section.
- Apply filters if needed.
- Click [Actions] –> [Select multiple records].
- Select the needed report in the [Print] button drop-down list.
Fig. 13. – Receiving the "Account Info” report from several records of the [Accounts] section
The report looks as follows (Fig. 14):
Fig. 14. – Example of the "Account Info” report based on several section records
See also