Question

Printable issue : Pick Detail Data in the Printable

Hi Team,

I think the PDF functionality should be added as an Out of the box otherwise it is very difficult to create. I want to develop at least 10 printable n my project and add it with the fast report would be difficult for me.

Now please tell me with the help of this code I am able to pick the current value in that Object like in that case values are Full Name, Gender, etc.

namespace Terrasoft.Configuration
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    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;
    using Terrasoft.Nui.ServiceModel.Extensions;
    using EntitySchema = Terrasoft.Core.Entities.EntitySchema;
    using EntitySchemaColumn = Terrasoft.Core.Entities.EntitySchemaColumn;

    // Name of the data provider class for the report, whose logic needs to be implemented.
    [DefaultBinding(typeof(IFastReportDataSourceDataProvider), Name = "ContactDataProvider")]
    public class ContactDataProvider : IFastReportDataSourceDataProvider
    {

        private Guid _entitySchemaUId = new Guid("16BE3651-8FE2-4159-8DD0-A803D4683DD3");
        // Name of the source code schema.
        private readonly string _resourceManagerName = "UsrContactDataSourceCode";
        private readonly string[] _localizableStringNames = new[] {
            "ReportTitle",
            "FullNameLabel",
            "BirthdayLabel",
            "GenderLabel",
            "AccountLabel"
        };

        // Populating the report columns.
        private IEnumerable> GetContactData(
            UserConnection userConnection,
            Guid entitySchemaUId,
            IEntitySchemaQueryFilterItem filter) {
                // Getting the object schema.
                var entitySchema = userConnection.EntitySchemaManager.GetInstanceByUId(entitySchemaUId);
                // Creating the object of the EntitySchemaQuery class.
                EntitySchemaQuery query = new EntitySchemaQuery(entitySchema);
                // Adding columns to query.
                query.AddColumn("Name");
                query.AddColumn("BirthDate");
                var gender = query.AddColumn("Gender.Name");
                var account = query.AddColumn("Account.Name");
                // Adding the created filter.
                query.Filters.Add(filter);
                // Getting the collection of contacts.
                var contacts = query.GetEntityCollection(userConnection);
                var contactsCollection = new Collection>();
                // Populating the report columns.
                foreach (var entity in contacts)
                {
                    contactsCollection.Add(new Dictionary {
                        ["Full name"] = entity.GetTypedColumnValue("Name"),
                        ["Birthday"] = entity.GetTypedColumnValue("BirthDate"),
                        ["Gender"] = entity.GetTypedColumnValue(gender.Name),
                        ["Account"] = entity.GetTypedColumnValue(account.Name)
                    });
                }
                return contactsCollection;
        }
        
        // Localization of the report title.
        private IEnumerable> 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, Guid entitySchemaUId,
                IReadOnlyDictionary parameters) {
            var managerItem = userConnection.EntitySchemaManager.GetItemByUId(entitySchemaUId);
            return parameters.ExtractEsqFilterFromReportParameters(userConnection, managerItem.Name) ?? throw new Exception();
        } 

        // Getting data.
        public Task GetData(UserConnection userConnection, IReadOnlyDictionary parameters) {
            var filter = ExtractFilterFromParameters(userConnection, _entitySchemaUId, parameters);
            var result = new ReportDataDictionary {
                // Populating the report columns.
                ["ContactData"] = GetContactData(userConnection, _entitySchemaUId, filter),
                ["LocalizableStrings"] = GetLocalizableStrings(userConnection)
            };
            return Task.FromResult(result);
        }
    }
}

 

1. Now please tell me how will I pick up the values from the Details or add other Object columns in the same printable records.

2. Also: Please tell me "line in bold" what is that Guid value for ? which id is it ? where to pick from any specific object.

Please answer both 1 and 2.

Like 0

Like

3 comments

Dear Bhumika,

 

Have you checked this addon - https://marketplace.creatio.com/app/asposepdf-connector-creatio? It should allow you to print Word reports in PDF and ease creation of printables.  

 

Best regards,
Angela

Hi Angela,

Thanks for the suggestions I have successfully uploaded on the system.

But how do I generate access keys (App Key, App SID) and fill in the system setting?  

How do I access key please deliver this.

Hello Bhumika,

 

Here is a guide on how to set up the Aspose.PDF connector for Creatio correctly:

1. Register at Aspose.PDF service (https://products.aspose.cloud/pdf/net), add an application (My Apps> Add an App), get access keys (App Key, App SID).
2. Fill in the system settings "Aspose API Access Key" and "Aspose Security Identifier (App SID)" with the data from item 1, respectively. Logout and login to the Creatio app again.
3. Go to System Designer > Lookups > the ‘Printables’ lookup, select the printable, and open the printable setup page, select the ‘Convert to PDF’ checkbox and save changes. Note that the ‘Convert to PDF’ checkbox is available only on the printable setup page in the new UI.

 

Please, let us know in case any further information is required. 

 

Best regards, 

Olga. 

Show all comments