Hello creatio team, 

 

I have successfully set up the printables show/hide feature based on the value from field(Currency). But it only works when record is opened from section page or navigated from other page. It doesn't work if I refresh the record page. (I don't have any section printable so only focusing on edit page printables. )

 

 I have tried adding the preparePrintFormsMenuCollection() on the edit page and apply the filter there so it could work on refresh. But the value of the currency field coming as undefined so I can apply static filter and that worked on refresh but if I want to add condition based on currency to show and hide I can't do it.

 

 

My code on Edit page: 

 

initCardPrintForms: function() {

this.callParent(arguments);

var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);

if (Ext.isEmpty(printMenuItems)) return;

 

printMenuItems.each(function(item) {

                               item.set("Visible", {bindTo: "getPrintMenuItemVisible"}); 

}, this);

},

 

getPrintMenuItemVisible: function(reportId) {

var currentCurrency = this.get("UsrCurrency") || { displayValue: "" };

var        printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),

item = printMenuItems.find(reportId);

 

if (Ext.isEmpty(item)) {

return false; // Ensure a boolean return

}        

                                 var caption = item.get("Caption") || "";

 

var isUsCurrency = currentCurrency.displayValue === "US";

 

var containsUs = caption.includes("-US");

 

return isUsCurrency === containsUs;

 

}, 

 

 

My code on section page: 

 

initQueryColumns: function(esq) {

this.callParent(arguments);

 

if (!esq.columns.contains("UsrCurrency")) {

esq.addColumn("UsrCurrency");

}

},

initCardPrintForms: function() {

this.callParent(arguments);

 

var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);

if (Ext.isEmpty(printMenuItems)) return;

 

printMenuItems.each(function(item) {

item.set("Visible", {bindTo: "getPrintMenuItemVisible"});

}, this);

},

getPrintMenuItemVisible: function(reportId) {

if (Ext.isEmpty(this.get("ActiveRow"))) return true;

 

var currentCurrency = this.get("GridData").get(this.get("ActiveRow")).get("UsrCurrency") || { displayValue: "" };

var        printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);

var        item = printMenuItems.find(reportId);

 

if (Ext.isEmpty(item)) return;

var caption = item.get("Caption") || "";

 

var isUsCurrency = currentCurrency.displayValue === "US";

 

var containsUs = caption.includes("-US");

 

return isUsCurrency === containsUs;

},

 

 

 

I have tried adding in the  preparePrintFormsMenuCollection()

 

 

preparePrintFormsMenuCollection: function(printForms) {

printForms.eachKey(function (key, item) {

if (!item.get("Caption")) {

item.set("Caption", item.get("NonLocalizedCaption"));

}

item.set("Tag", key);

if (item.get("TypeColumnValue")) {

item.set("Visible", { bindTo: "getPrintMenuItemVisible" });

}

 

var currentCurrency = this.get("UsrCurrency");

console.log("## currentCurrency", currentCurrency);

 

    var caption = item.get("Caption") || "";

If(currentCurrency.displayValue === "US"){

item.set("Visible", caption.includes("-US"));

}

}, this);

}

Like 0

Like

6 comments

The reason why this happens is when you open a page from the section you are in combined mode and the logic for the print menu comes from the Section schema. When you refresh, the edit page only opens in edit mode, in this case the logic is coming from the Page schema (when you refresh, note that the tab on the left to popout the section list to navigate is no longer there). Basically, your logic needs to be implemented on both the section schema and also on the page schema to handle both cases. There are a few community posts on this that show both sides, perhaps this or this might help to piece together the details.

Ryan

Ryan Farley,

Hello Ryan, highly appreciate your response. As I have attached above, I have included the code on edit page as well. Seems like edit page code doesn't work. I have exactly similar code as your article but edit page code doesn't apply the filter. I see couple of person commented on below the article and they are facing the same issue. Did we find the work around yet?

 

Hello Creatio support do we have solution for this?

The problem here is that on Edit page initCardPrintForms method is called before onEntityInitialized so the field value is undefined because it hasn't been initialized yet. It's the known issue and we have already registered a request to our R&D team to address that.

Iryna Oriyenko,

Thank you for the response but isn't really there a way to reload or refresh the print records after the entity has been initialized? 

Tony Stark,

So for workaround, Can we create the new dropdown next to 'PRINT' button dropdown? 

 

Since we can't have dependent on value of field, I can have predefined filter for those dropdown it will only show them. The reason is we have long list of printables and we want to organize them. Thank you!

Show all comments

Hello creatio experts, 

 

I want to show/ hide printables based on currency field. If the currency is us then show the printable which names contains '-US' in them. I have tried follow this article but the field value is getting undefined as the time this function run entity might not be initialized. I mainly want to do this for edit page.  

 

My code: 

 

initCardPrintForms: function() {

this.callParent(arguments);

var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);

if (Ext.isEmpty(printMenuItems)) return;

 

printMenuItems.each(function(item) {

                               item.set("Visible", {bindTo: "getPrintMenuItemVisible"}); 

}, this);

},

 

getPrintMenuItemVisible: function(reportId) {

var type = this.get("UsrCurrency") || { displayValue: "" },

console.log("## UsrCurrency", UsrCurrency);

var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),

item = printMenuItems.find(reportId);

if (Ext.isEmpty(item)) {

return false; // Ensure a boolean return

}                                

                                 var caption = item.get("Caption") || "";

 

return type.displayValue === "US Dollar" ? caption.includes("-US") : true;

},

 

Alternatively, I have tried this but printforms and currency come undefined

 

 

        preparePrintFormsMenuCollection: function(printForms) {

           printForms.eachKey(function (key, item) {

               if (!item.get("Caption")) {

                   item.set("Caption", item.get("NonLocalizedCaption"));

               }

               item.set("Tag", key);

               if (item.get("TypeColumnValue")) {

                   item.set("Visible", { bindTo: "getPrintMenuItemVisible" });

               }

               var currentCurrency = this.get("UsrCurrency");

               console.log("## currentCurrency1", currentCurrency);

               var isCurrencyEmpty = Ext.isEmpty(currentCurrency);

               var currentCurrencyDisplayValue = isCurrencyEmpty ? "" : currentCurrency.displayValue || "";

               if (!isCurrencyEmpty && currentCurrencyDisplayValue=="US Dollar" && item.get("Caption").includes("-US")){

               item.set("Visible", true);

               }

               else {

               item.set("Visible", false);

               }

           

           }, this);

       },

 

We already have getModulePrintFormsESQ() on the edit page and if add filter there for currency it would hide the remaining printable in list but this function only responsible for creating query so this doesn't refresh the list of printables as value of currency is undefined at the first call.

Like 0

Like

3 comments

Hello Tony,

 

The logic of forming the list of reports that are displayed in the "Print" button added to the page is hardcoded in the _generateMenuItems method in the core Angular files of the app. It doesn't contain the "visible" property and selects printables for the current entity only once when the page is refreshed or the entity is opened and then forms an array of printables using filter.map chain and return this array for the button. And we cannot override the logic of the _generateMenuItems method.

 

So in order to hide printables you have to add the filters like that:


 

initCardPrintFormsEsqFilters: function(esq) {
	esq.filters.addItem(Terrasoft.createColumnFilterWithParameter(Terrasoft.ComparisonType.CONTAIN,
	"Caption",
	"testStringValue"));
}

 

The problem here is that initCardPrintFormsEsqFilters method is called before onEntityInitialized so the record fields are not initialized yet so their values are undefined.

 

Meanwhile we will create a request for our R&D team to implement the possibility of filtration button options using custom handlers and also possibility of filtration of printables list also using a custom handler.

 

Thank you for reporting this idea to us and helping us in making the app better!

Iryna Oriyenko,

Relying same text here for future refrences: 

 

Thank you for the response but isn't really there a way to reload or refresh the print records after the entity has been initialized? 

Currently the printables are selected only once when the page is refreshed or the entity is opened. Other changes that are made to printables later in the page life cycle (e.g. adding filters) will not have the effect and the printables list will remain the same as it was created during the initialization.

Show all comments

How to setup template and print functionality using 8.2.0.4183 version?

Like 0

Like

2 comments

Thanks Kumar, could you please also help with the template creation which then should be printed?

 

Show all comments

Hi

 

I want to change the text in printable based on the two values of printable. Please let me know if there is any way we can do that.

 

Regards

Rakshith Dheer

Like 0

Like

1 comments

To accomplish this, what I typically do is add the macro to the record Id, then in the macro use an ESQ to get the needed values and return the result. You can get the UserConnection in the macro using something like this: 

namespace Terrasoft.Configuration 
{
  using System;
  using Terrasoft.Common;
  using Terrasoft.Core;
  using Terrasoft.Core.DB;
  using Terrasoft.Core.Entities;
  using Terrasoft.Core.Packages;
  using Terrasoft.Core.Factories;
  using System.Globalization;
 
  [ExpressionConverterAttribute("MyMacro")]
  public class UsrMyMacro: IExpressionConverter 
  {
    public string Evaluate(object value, string arguments = "") 
    {
 
      // value passed in is an Id of some record
 
      var result = "";
 
      if (value != null) 
      {
        UserConnection userConnection = null;
        try
        {
          userConnection = (UserConnection) System.Web.HttpContext.Current.Session["UserConnection"];
        }
        catch {}
        if (userConnection == null) return result;
 
        var esq = new EntitySchemaQuery(userConnection.EntitySchemaManager, "UsrSomeEntity");
        esq.AddColumn("UsrSomeField1");
        esq.AddColumn("UsrSomeField2");
 
        var entity = esq.GetEntity(userConnection, Guid.Parse(value.ToString()));
        if (entity != null) 
        {
          var val1 = entity.GetTypedColumnValue<string>("UsrSomeField1");
          var val2 = entity.GetTypedColumnValue<string>("UsrSomeField2");
 
          result = val1 + " " + val2;
        }
      }
      return result;
    }
  }
}

One thing to note that is an issue if running the printable from a process with a timer, you'll be unable to get the UserConnection because in those cases the Session will be null.

Ryan

Show all comments

Hello Community,

We are looking to implement functionality that allows printing of only the selected records from a detail list on a list page. All the selected records should be consolidated into a single document, rather than generating multiple documents for each selected record.

 

Any guidance or best practices on how to achieve this would be greatly appreciated.

 

Thank you!

Like 0

Like

1 comments
Best reply

Hello,
 

Unfortunately, the functionality you mentioned with the button is not being implemented. 

Printed forms work so that they print the information contained in a single record of a section. One section record equals one report. If the task is to include information about multiple records in one report, it is better to create a separate section for this purpose, where you can add fields and details that will reference specific records via reverse relationships. This way, you can include data from multiple records in the report.
 

Printable forms are generated as one document per section record. If you want to implement your own logic for working with printed forms using development tools, you can look into the client schema "PrintReportUtilities," which interacts with "ReportService" on the server side.
 

It would be best if you implemented something similar to ReportService.

Hello,
 

Unfortunately, the functionality you mentioned with the button is not being implemented. 

Printed forms work so that they print the information contained in a single record of a section. One section record equals one report. If the task is to include information about multiple records in one report, it is better to create a separate section for this purpose, where you can add fields and details that will reference specific records via reverse relationships. This way, you can include data from multiple records in the report.
 

Printable forms are generated as one document per section record. If you want to implement your own logic for working with printed forms using development tools, you can look into the client schema "PrintReportUtilities," which interacts with "ReportService" on the server side.
 

It would be best if you implemented something similar to ReportService.

Show all comments

Hi Community,

Im trying to download the Notes of a Classic Ui Section, to a Word printable.

The end result in the Word printable is together with the Html Tags. How can we fix this?

Sasori

Like 0

Like

1 comments

Dear Sasori,

 

As of now, it's not possible to correctly display the field with HTML formatting in the printable.  


We registered a query for our R&D team and await a fix in the upcoming versions. 

 

As a workaround suggestion, you can replace the Notes field with a simple text field. I understand that it's missing the format settings and cannot be applied to tables, but it should work for a sentence or two simple comments. 

 

Thank you for making Creatio better!

Show all comments

I want to create a report which prints all Lead records. For example, Leads in a particular stage, Leads created in last month etc 

Like 0

Like

1 comments

Hi,

 

Printed forms work so that they print the information contained in a single record of a section. One section record equals one report. If the task is to include information about multiple lead records in one report, it is better to create a separate section for this purpose, where you can add fields and details that will reference specific records via reverse relationships. This way, you can include data from multiple records in the report.

Printable forms are generated as one document per section record. If you want to implement your own logic for working with printed forms using development tools, you can look into the client schema "PrintReportUtilities," which interacts with "ReportService" on the server side. 

It would be best if you implemented something similar to ReportService.

Show all comments

Hello Creation Community,

I have developed functionality that displays printables based on specific configurations. I have overridden the initCardPrintForms method and other necessary methods. However, I've encountered an issue: this development works correctly only when the page is rendered for the first time.
I need to refresh the list of printables whenever the "Product" field, used as a filter, is updated. Here's the relevant code snippet:

onProductUpdate: function(){
debugger;
this.setFZSelectedApp(this.$PrimaryColumnValue, true, null);
this.initCardPrintForms();
},
Even though the collection of printables updates during debugging, the action buttons, including the print button, do not reflect these changes.
Based on my developments the "Application form report" should be excluded after the product was updated.

Displaying image.png

Like 1

Like

1 comments

Hello,
Look at this discussion, I believe you can find useful information there.

Show all comments

Hi all,

 

In our project we are producing with Creatio application some printable document (.pdf and .doc).

 

In these document we are inserting some Rich Text fields but in the document produced we are not able to visualize/report all the style changes done on the Rich Text field.

 

Do you have any suggestion?

 

Best Regards

 

Stefano

Like 0

Like

2 comments

Hello,

 

As of now, it's not possible to correctly display the field with HTML formatting in the printable.  


Our R&D team has already been informed and is currently working on the mentioned issue.


As a workaround suggestion, you can replace the rich text field with a simple text field. We understand that it’s missing the format settings and cannot be applied to tables, but it should work for a sentence or two simple comments.  

 

Thank you for being an active part of the community and helping to make Creatio better!

Hello Hanna,

Thank you very much for your response

Regards

Stefano

Show all comments

Hello, 

 

I have two field called A and B in one of my printable word document. I want to add condition if A field is filled on record then print document with A field's value and if A is not filled on specific record print document with B field's value. How can I achieve this? I have tried adding condition in word document template with ctrl +F9 with if statement but it doesn't seem to work fully. Alternative is adding marco but it will change the document type to .docm and creatio doesn't allow to submit this file type as template

Like 0

Like

2 comments
Best reply

Halyna Parkhomenko,

Cool Sounds good. In my scenario I had about 17 printables that needed update and doing for all would be very consuming. I found an alternative. I have put the logic of printing marco based on condition( empty string when one)  in to source code C# file and it worked for me. Thanks!

Hello, 

To implement this logic, you can configure 2 printable templates. The first for condition A is filled in, the second for all other cases. 


After that, you need to set up a business process that will determine whether field A is filled and, depending on this, will choose the printed form you need. 
 

Such a business process will look something like this: 

1. Read the value of your field from the record 
 

 

2.  Add an element with the help of which we will attach the file to our request at the end. 

 

3. Add condition flow and check and check if our field is empty 
 

[#Check if field "A" fill in.First item of resulting collection.Resolution#]=="" 
 

4. Generate Report and connect it to your record by ”Id” parametr 

 

 

5. After that, add a button to the page that will start this process and download the necessary file for recording. 

 

  

You can read more about setting up business processes in the following article: 
 

https://academy.creatio.com/docs/8.x/no-code-customization/bpm-tools/business-process-setup/process-designer 
 
 

Halyna Parkhomenko,

Cool Sounds good. In my scenario I had about 17 printables that needed update and doing for all would be very consuming. I found an alternative. I have put the logic of printing marco based on condition( empty string when one)  in to source code C# file and it worked for me. Thanks!

Show all comments