Announcement

Collapse
No announcement yet.

Can't enable Print to PDF in custom entity

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't enable Print to PDF in custom entity

    I have created a custom entity, I need to enable print to PDF from there. Please help how it can be enabled.

  • #2
    First you need to create a template for your custom entity:

    Menu>Templates>Create Template
    Select your custom entity type from the Entity Type select element
    Enter your template values
    The button 'Print Pdf' will be automatically added in the entity's detail upper left drop down menu.

    This is executed by the 'views/record/detail.js' script when there is a Template record with the entityType value equal to the custom entity.

    Comment


    • #3
      Hi everyone, I am Denis, i am new to espocrm. i am facing the issue:
      I want to disbable the "print to pdf" button in sales order module. but when i comment the the print function in client/src/views/record/details.js,
      it removes "print to pdf" button in (quote, invoice, salesOrder).

      Can someone Help, please!
      Thanks in advance

      Note: i was able to hide the "duplicate" button by adding
      "duplicateDisabled"=true
      in custom/ressources/metadata/clientDefs/Entity.json.

      Is there an attribute like "duplicateDisabled" that we can use to disable "print to pdf" button???

      Comment


      • #4
        Hello, I don't believe that there is a metadata setting to remove the pdf print button.

        You can do it by creating a custom view for any entity on which you want to remove the button.

        We don't use the sales module our application but we have a custom entity called ServiceTicket where we wanted to remove the "print to PDF" button and it was done as follows:

        created file: client/custom/src/views/service-ticket/record/detail.js
        Code:
        Espo.define('custom:views/service-ticket/record/detail', 'views/record/detail', function (Dep) {
        
          return Dep.extend({
        
            setupActionItems: function () {
        
              // execute the setupActionItems function from the original script
              Dep.prototype.setupActionItems.call(this);
        
              // remove the print to pdf button
              this.removeButton('printPdf');
        
            }
        
          });
        });
        modified file: custom/Espo/Custom/Resources/metadata/ServiceTicket/clientDefs.json
        Code:
        {
          "recordViews": {
            "detail" : "custom:views/service-ticket/record/detail"
            }
        }
        After the changes, flush the cache and rebuild.

        As a side note, I don't recommend changing the original scripts as your modifications will be wiped out by any updates, instead always create scripts in the "Custom" namespace, just like Espo does when you create new entities or fields using the Administration GUI.
        Last edited by telecastg; 03-29-2020, 10:20 PM.

        Comment


        • denis.yougang
          denis.yougang commented
          Editing a comment
          Thanks telecastg for the explanations, i will try this.

        • telecastg
          telecastg commented
          Editing a comment
          You're welcome, of course yuri solution is the correct one, or at least a lot less complicated

      • #5
        If you remove PDF Template record for Sales Order (there is a default one), then 'Print to PDF' action should be automatically removed.

        Comment


        • denis.yougang
          denis.yougang commented
          Editing a comment
          Thanks yuri i removed the template and it's working fine
      Working...
      X