Announcement

Collapse
No announcement yet.

Custom button into detail view

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

  • Custom button into detail view


    Hi, I read many posts related to the topic but I don't want to solve the problem, I would like to add a button next to the edit button but I can't do it, I also followed the indications of this post https://forum.espocrm.com/forum/gene...ss-limitations but I can't.


    First of all I created the folders src - views - TargetList - Record in the "client/custom" path because they didn't exist. Then I wrote the detail.js file in this path: "client/custom/src/views/TargetList/record"
    Code:
    Espo.define('custom:views/TargetList/record/detail', 'views/record/detail', function (Dep) {
         return Dep.extend({
    
              setupActionItems: function () {
    
                   this.dropdownItemList.push({
    
                        label: 'Invia Email CCN',
                        name: 'InviaEmailCCN'
                   });
              },
    
         actionInviaEmailCCN: function () {
                   var templateId = this.model.get("templateId");
                   window.open('?entryPoint=TargetListInviaEmailCCN&e ntityType='+this.model.name+'&entityId='+this.mode l.id+'&templateId=' + templateId, '_blank');
              }
         });
    });
    subsequently I created the php files as indicated in the post but when I delete and reconstruct the Backend and access the destination list I don't see the button, you can help me it's really important
    Last edited by enricorossa; 09-05-2019, 06:52 AM.

  • #2
    in client/custom/src/views/real-estate-property/detail.js i add this code:

    Code:
    Espo.define('custom:views/real-estate-property/detail', 'views/detail', function (Dep) {
    
        return Dep.extend({
    
            setup: function () {
                Dep.prototype.setup.call(this);
    
    
    
                this.menu.buttons.push({
                    label: 'Test',
                    name: 'test',
                    link: '#test'
                });
            }
    
        });
    });

    Rebuild, refresh but button doesn't apear. What I am doing wrong?

    Comment


    • #3

      If I edit this file client/modules/crm/src/views/target-list/record/detail.js the action appears.

      But if I load the detail.js in the path client/custom/src/views/target-list/record/ the action does not appear, can I tell why?

      P.S. I corrected the file this way because the module was not TargetList but target-list

      Code:
      Espo.define('custom:views/target-list/record/detail', 'views/record/detail', function (Dep) {
      
          return Dep.extend({
      
              setupActionItems: function () {
                  Dep.prototype.setupActionItems.call(this);
                  this.dropdownItemList.push({
                      'label': 'Invia Email CCN',
                      'name': 'InviaEmailCCN'
                  });
      
              },
              actionInviaEmailCCN: function () {
      
                  console.log('dentro');
              }
      
          });
      });

      Comment


      • #4
        Code:
        this.menu.buttons.push({
                        label: 'PDF',
                        name: 'pdf',
                        link: '/pdf/?id='+this.model.get('propid')
                    });

        when i open record and click button value of my custom field "propid" is undefinied, but when i open record and refresh page and then click button it's ok. Why?

        Comment


        • ttm
          ttm commented
          Editing a comment
          If i choose not custom field (e.g. id, name, number, etc.) it's ok. Problem is only with custom fields.

        • ttm
          ttm commented
          Editing a comment
          and tell me please how open this link in new window?

      • #5
        Please someone who has had this same problem can help me? thank you

        Comment


        • #6
          I was able to press the button, and later publish it as I did.

          Now I have defined an action that lists all the relationships with the distribution list and I would like to capture the list of all the associated records.

          Code:
          actionListaRecordRelation: function () {
          
                      var scope = this.scope;
          
                      this.wait(true);
                      this._helper.layoutManager.get(this.model.name, 'relationships', function (layout) {
                              var panelList = layout;
                              panelList.forEach(function (item) {
          
          [B][COLOR=#FF0000]// here I would like to capture all the linked records and turn them into JSON arrays[/COLOR][/B]
          
          
                              }.bind(this));
          
                              this.wait(false);
                      }.bind(this));
                  }
          Do you have any idea how I can do it? thank you

          Comment


          • #7
            Your button is working in custom? If yes - what did You do that button appear? You change something in code or place file in another folder?

            Comment


            • #8
              1) I uploaded my file to the client/custom/src/views/target-list/detail.js path

              detail.js
              Code:
              Espo.define('custom:views/[B]target-list[/B]/record/detail', 'views/record/detail', function (Dep) {
              
                  return Dep.extend({
              
                      setupActionItems: function () {
              
                          Dep.prototype.setupActionItems.call(this);
                          this.dropdownItemList.push({
                              'label': 'Button Label Name',
                              'name': '[B][COLOR=#FF0000]YourActionName[/COLOR][/B]'
                          });
              
                      },
                      action[B][COLOR=#FF0000]YourActionName[/COLOR][/B]: function () {
              
              [B][COLOR=#FF0000]// YOUR CODE [/COLOR][/B]
              
                      }
              
              
                  });
              });
              2) Then I created the view and uploaded into custom/Espo/custom/Resources/metadata/clientDefs/TargetList.json
              Attention the name of the view file (only the name of this .json file) must be what you see in the url when you access your form in my case not target-list.json but TargetList.json
              Click image for larger version

Name:	Immagine2.png
Views:	522
Size:	3.5 KB
ID:	51505

              TargetList.json
              Code:
              {
                  "recordViews": {
                      "detail": "custom:views/target-list/record/detail"
                  }
              }
              3) Administration->Rebuid
              4) Access the details of your record and reload the page

              Click image for larger version

Name:	Immagine.png
Views:	464
Size:	21.0 KB
ID:	51506

              Comment


              • #9

                I close the post and re-open one for the other topic

                Comment


                • #10
                  Thank You!

                  Comment

                  Working...
                  X