Announcement

Collapse
No announcement yet.

Opportunities Template > PDF

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

  • tanya
    commented on 's reply
    In which one row from what file?

  • huscmk
    commented on 's reply
    It seems that the json syntax in clientDefs file is valid.
    In the data/cache/application/metadata.php, I can find :

    Code:
    (...)
        'Client' => 
        array (
          'controller' => 'controllers/record',
          'views' => 
          array (
            'detail' => 'custom:views/client/detail',
          ),
    (...)
    I have noticed something that may speak to you. After these modifications, I cannot open the edit view of an entry of the concerned custom entity. When I look into the console, I can see the following error :

    Code:
    Uncaught TypeError: Cannot read property 'push' of undefined
        at child.setup (eval at _execute (espo.min.js?r=1527897572:17), <anonymous>:35:35)
        at child.initialize (espo.min.js?r=1527897572:16)
        at child.Backbone.View (espo.min.js?r=1527897572:6)
        at child [as constructor] (espo.min.js?r=1527897572:6)
        at child [as constructor] (espo.min.js?r=1527897572:6)
        at child [as constructor] (espo.min.js?r=1527897572:6)
        at child [as constructor] (espo.min.js?r=1527897572:6)
        at new child (espo.min.js?r=1527897572:6)
        at Bull.Factory.<anonymous> (espo.min.js?r=1527897572:16)
        at Bull.Factory._getViewClass (espo.min.js?r=1527897572:16)
    Any idea ?
    Thanks

  • tanya
    commented on 's reply
    Is json in your clientDefs file valid?
    check in data/cache/application/metadata.php
    clientDefs > Client > views > detail > ?

  • huscmk
    commented on 's reply
    tanya I have added the following at the beginning of the file

    custom/Espo/Custom/Resources/metadata/clientDefs/Client.json

    inside of the main brackets:

    "views": {
    "detail": "custom:views/client/detail"
    },


    I guess I am missing something in this part.

  • tanya
    replied
    did you set this view in custom clientDefs?

    Leave a comment:


  • huscmk
    commented on 's reply
    tanya Thanks a lot for the reply. Actually, I used "myCustomEntity" in my question post as a placeholder.
    The actual name of my custom entity is "client" so the detail.js is located here :

    /client/custom/src/views/client/detail.js

    and its first line is :

    Espo.define('custom:views/client/detail', 'views/detail', function (Dep) {

    Thanks again for the support.

  • tanya
    replied
    replace myCustomEntity with my-custom-entity

    Leave a comment:


  • huscmk
    replied
    Hi,

    I am trying to replicate what's explained in this topic to add the action "Email PDF" in the detail view. I must be missing something because I can't make it work. The button is not showing at all.

    It is for a custom entity for which I have created PDF template (that I can generate without problem). I have the latest version of espoCRM and I have Advanced Pack as well. I would like to add the option to Email the PDF just as it is natively possible with Quote entity but for my custom entity.

    I created the a file /client/custom/src/views/myCustomEntity/detail.js with the same code as above except that I have replace "opportunity" by "myCustomEntity"

    Any idea what I am missing out ? What are the files that I have to create/update to make this work ?

    Any help would be highly appreaciated
    Thanks a lot in advance

    Leave a comment:


  • PGI
    commented on 's reply
    It worked! Thank you

  • tanya
    replied
    Hello,
    did you override Opportunity clientDefs?
    Did you rebuild Espo? (Administration > Rebuild)
    Did you refresh the page?

    Leave a comment:


  • PGI
    replied
    Hello,

    To add my button, I created a file detail.js in the following folder:
    /client/custom/src/views/opportunity/detail.js

    This file contains the following code:

    Code:
    Espo.define('custom:views/opportunity/detail', 'views/detail', function (Dep) {
    
        return Dep.extend({
    
            setup: function () {
                Dep.prototype.setup.call(this);
                this.dropdownItemList.push({
                    name: 'printPdf',
                    label: 'Print to PDF'
                });
    
                this.dropdownItemList.push({
                    name: 'composeEmail',
                    label: 'Email PDF'
                });
    
                if (this.getAcl().checkModel(this.model, 'edit')) {
                    this.dropdownItemList.push({
                        'label': 'Duplicate',
                        'name': 'duplicate'
                    });
                }
    
            },
    
            actionPrintPdf: function () {
                this.createView('pdfTemplate', 'Modals.SelectTemplate', {
                    entityType: this.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));
            },
    
            actionComposeEmail: function () {
                this.createView('pdfTemplate', 'views/modals/select-template', {
                    entityType: this.model.name
                }, function (view) {
                    view.render();
                    this.listenToOnce(view, 'select', function (model) {
                        this.notify('Loading...');
                        this.ajaxPostRequest('Quote/action/getAttributesForEmail', {
                            quoteId: this.model.id,
                            templateId: model.id
                        }).done(function (attributes) {
                            var viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') || 'views/modals/compose-email';
                            this.createView('composeEmail', viewName, {
                                attributes: attributes,
                                keepAttachmentsOnSelectTemplate: true
                            }, function (view) {
                                view.render();
                                this.notify(false);
                            }, this);
                        }.bind(this));
                    }, this);
                }, this);
            }
    
        });
    });
    But the button to export to PDF does not appear.

    I don't know what my error is.

    I consulted all the links given by Tanya , thank you very much, but I'm not good enough to succeed without your help...

    Thank you

    Leave a comment:


  • PGI
    replied
    Good morning. Hello,

    I looked at the link, thank you.

    I understand the principle but I'm looking for the file to modify. Can you tell me what his path is, please?

    Thank you

    Leave a comment:


  • tanya
    replied
    Hello
    you need to create this button in the view
    Hi! I'm trying to implement a custom button with action on it (as entryPoint) The code in detail.js: Espo.define('custom:views/style-expert

    Leave a comment:


  • PGI
    started a topic Opportunities Template > PDF

    Opportunities Template > PDF

    Hello,

    I created a template for opportunities (from https://url/#Template).
    Now, I want to be able to print an opportunity (or create a PDF) as defined in the template... but I don't know how to do it. There is no button to create a PDF when I list opportunities or edit an opportunity.

    I searched the forum, but I can't find an answer (or I don't understand ).
    Can you help me, please?

    Thank you very much!
Working...
X