Announcement

Collapse
No announcement yet.

Print To PDF for Custom Entities

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

  • Print To PDF for Custom Entities

    Hi there,

    I try to add Print To PDF support for my Custom Entities in detail view just like advanced - Quote.

    I create client/custom/src/views/MyEntity/record/detail.js . I copied detail.js from Advanced... quote/record.
    and also add to my custom entityDefs - MyEntity.json to "recordViews": {"detail": "Custom:MyEntity.Record.Detail"}

    But It did not work..
    But if I use "recordViews": {
    "detail": "Advanced:Quote.Record.Detail"} in entitydef/MyEntity.jso it works..bu it is not good way...!

    What is the magic to get it working.

    thnx & rgdrs,

    Selcuk




  • #2
    Hi

    The problem that your entity is not listed? Add "object": true to metadata > scopes > CustomEntity.json

    Comment


    • #3
      Hi,

      I've already added "object:true" for Templates..

      Comment


      • #4
        "object": true for your custom entity

        Comment


        • #5
          Yes, right, I mean I added to all my CustomEntiies object:true to select my CustomEntities in Templates regarding ealrlier.
          post I solved my issue by modifiying clien/src/vies/record/detail.js but now I need to check this file for new updates / upgrades.

          Comment


          • #6
            Can you write here your changes in detail.js?

            Comment


            • #7
              I've added 2 buttons with actions in setup function.for My entiies.. Creaete PDF , ( Same a as yours Print To PDF), and Create GPR (Special Report Generaitıon for me ) setup: function () {.........................

              var modname = this.model.name;
              if (modname =='CustENT1' || modname ==CusENT2|| modname =='CustENT3' || modname =='CustENT4' )
              {
              this.dropdownItemList.push({name: 'printPdf', label: this.translate('Create PDF','labels') }); // your action 'Print To PDF
              this.dropdownItemList.push({'label': this.translate('Create GPR','labels'),'name': 'gpr' }); // My Action, opens new page
              }
              .......................

              actionGpr: function()
              {
              var tok = this.getUser().get('userName') + ':' + this.getUser().get('token');
              var tok64 = btoa(tok);
              var newur = "....../CreateGPP.php?ent=" + this.model.name + "&enid="+ this.model.id+ "&tk="+tok64;

              window.open(newur,'_blank');
              }

              fyi,

              take it easy,

              Selcuk




              Comment


              • #8
                Edit: The user guide fixes this issue I think (https://github.com/espocrm/documenta...ting-to-pdf.md). It seems like EspoCRM handles "Print to PDF" in detail view with templates now.




                yuri What have I done wrong? I'm trying to implement the same thing (Print to PDF for all of my entities), but it isn't working. So far, I'm only trying to make it work with my Project entity. I created this file:

                PHP Code:
                fileclient/custom/src/views/project/detail.js

                Espo
                .define('custom:views/project/record/detail''views/record/detail', function (Dep) {
                  return 
                Dep.extend({

                    
                setup: function () {
                      
                Dep.prototype.setup.call(this);

                      var 
                printPdfAction false;
                      
                this.dropdownItemList.forEach(function (item) {
                        if (
                item.name === 'printPdf') {
                          
                printPdfAction true;
                        }
                      }, 
                this);
                      if (!
                printPdfAction) {
                        
                this.dropdownItemList.push({
                          
                name'printPdf',
                          
                label'Print to PDF'
                        
                });
                      }
                    },

                    
                actionPrintPdf: function () {
                      
                this.createView('pdfTemplate''views/modals/select-template', {
                        
                entityTypethis.model.name
                      
                }, function (view) {
                        
                view.render();

                        
                this.listenToOnce(view'select', function (model) {
                          
                window.open('?entryPoint=pdf&entityType='+this.model.name+'&entityId='+this.model.id+'&templateId=' model.id'_blank');
                        }, 
                this);
                      }.
                bind(this));
                    }
                  });
                }); 
                I don't understand if I'm supposed to make more files. Nothing is in my Project->Actions menu:

                Click image for larger version  Name:	1.png Views:	1 Size:	8.3 KB ID:	34856

                Am I supposed to make a template or something? I double checked and my entity has "object":true in metadata->scopes.
                Last edited by bandtank; 02-21-2018, 02:31 AM.

                Comment

                Working...
                X