Creating Custom Buttons (with custom actions)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • irvingbach
    Junior Member
    • Apr 2015
    • 5

    Creating Custom Buttons (with custom actions)

    Hi Yuri!

    I want to customize my EspoCRM, i want to generate some specific reports por some custom Entities. My question is how can i create a button which calls a new window (calling an specific PHP document) and display the info that i need to print. Is it possible?
  • tarasm
    Super Moderator
    • Mar 2014
    • 573

    #2
    Yes, it's possible. You have to add to your view detail.js file the code:
    Code:
    this.menu.actions.push({
        'label': 'Custom Action',
        'action': 'customAction',
        'acl': 'edit'
    });
    Example you find in the file client/modules/crm/src/views/call/detail.js
    Job Offers and Requests

    Comment

    • yuri
      Member
      • Mar 2014
      • 8624

      #3
      You can do it also in metadata > clientDefs.

      Example:
      application/Espo/Modules/Crm/Resources/metadata/clientDefs/Campaign.json
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • irvingbach
        Junior Member
        • Apr 2015
        • 5

        #4
        Thank you! Both options worked fine!

        Comment

        • info@jaguarsoft.com
          Member
          • Apr 2015
          • 35

          #5
          Hi there!

          As suggested above, I have added my custom button to my custom.json for detail. Button shown OK and goes to target (in my case my custom pdf entity)

          is there any easy way to pass parameters to target like ; detail": {"buttons": [
          ...........
          "link": "#Pdf?ent={entityType}&entid=
          {entityId}",

          Thanks in advance,

          Selcuk


          Comment

          • yuri
            Member
            • Mar 2014
            • 8624

            #6
            You need to create action in js view file. You can take Email as an example.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • homeempire
              Senior Member
              • Sep 2014
              • 181

              #7
              How can I make button link to: " tel: {AccountName} " ?

              Comment

              • ming
                Junior Member
                • Oct 2018
                • 18

                #8
                guys..could you guys give me the code to create the custom button please. its been a week i trying all by myself.

                Comment

                • rodrigocoelho
                  Active Community Member
                  • Jun 2016
                  • 296

                  #9
                  It would be good to have a complete example. Maybe a tutorial.

                  Comment

                  • yuri
                    Member
                    • Mar 2014
                    • 8624

                    #10
                    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                    Comment

                    • sttn
                      Junior Member
                      • Apr 2020
                      • 26

                      #11
                      I tried the example and it does not work with Version 5.8.3. I cleen the cache, reload the page etc...

                      Comment

                      • sttn
                        Junior Member
                        • Apr 2020
                        • 26

                        #12
                        I get following error in the debugger from Chrome:

                        VM7991:257 Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined
                        at child.eval (eval at _execute (loader.js:94), <anonymous>:257:30)
                        at Array.forEach (<anonymous>)
                        at child.showHeaderActionItem (eval at _execute (loader.js:94), <anonymous>:256:48)
                        at child.controlButtonVisibility (eval at _execute (loader.js:94), <anonymous>:22:27)
                        at child.initSomeName (eval at _execute (loader.js:94), <anonymous>:12:18)
                        at eval (eval at _execute (loader.js:94), <anonymous>:78:60)
                        at Espo.Loader.load (loader.js:292)
                        at Espo.Loader.require (loader.js:154)
                        at root.require.Espo.require (loader.js:423)
                        at eval (eval at _execute (loader.js:94), <anonymous>:76:29)

                        Comment

                        • Kyle
                          Senior Member
                          • May 2020
                          • 143

                          #13
                          I also have followed the documentation example and get the same error as sttn when viewing any record that has the button hidden due to the status. If the status of the record allows for the button to be shown then everything works fine, however if the button is hidden then there is the JS error. TypeError: Cannot read property 'forEach' of undefined

                          I commented the code inside the controlButtonVisibility function and was able to continue working. Any help on how to avoid the error when hiding the button would be appreciated.

                          Comment

                          • yuri
                            Member
                            • Mar 2014
                            • 8624

                            #14
                            Debug client/src/views/main.js showHeaderActionItem. For some reason you have property 'menu' defined in a wrong way. Could be that you messed it in metadata > clientDefs.
                            Last edited by yuri; 06-16-2020, 02:30 PM.
                            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                            Comment

                            Working...