Button in Accout/view/ to create a new contact in Full-Edit-View

Collapse
X
Collapse
+ More Options
Posts
 
  • Time
  • Show
Clear All
new posts
  • CRM-BE
    Junior Member
    • May 2021
    • 13

    Button in Accout/view/ to create a new contact in Full-Edit-View

    Hello,

    I'm trying to set up a new button in Account/view/
    to create a new contact in Full-Edit-View.

    Can anyone help me?​
  • Kharg
    Senior Member
    • Jun 2021
    • 451

    #2
    clientDefs/Account.json

    PHP Code:
    {
        
    "menu": {
            
    "detail": {
                
    "buttons": [
    "__APPEND__",
                    {
                        
    "label""Create Contact",
                        
    "link""#Contact\/create",
                        
    "acl""create",
                        
    "style""primary"
                    
    }
                ]
            }
        }
    }
    ​ 
    Last edited by Kharg; 09-22-2024, 01:46 PM.

    Comment

    • CRM-BE
      Junior Member
      • May 2021
      • 13

      #3
      Hello,
      thanks, it works with:​

      "menu": {
      "detail": {....​

      can the parameter AccoutId be transmitted?​

      Comment

      • Kharg
        Senior Member
        • Jun 2021
        • 451

        #4
        You will have to use an action handler

        clientDefs/Account.json

        PHP Code:
        {
            
        "menu": {
                
        "detail": {
                    
        "buttons": [
                    
        "__APPEND__",
                        {
                            
        "label""createContact",
                               
        "name""newContact",
                            
        "action""newContact",
                            
        "style""primary",
                            
        "acl""create",
                            
        "aclScope""Contact",
                            
        "handler""custom:contact-handler",
                            
        "initFunction""initNewContact",
                            
        "actionFunction""newContact",
                            
        "checkVisibilityFunction""isNewContactVisible"
                        
        }
                    ]
                }
            }
        }
        ​ 
        client/custom/src/contact-handler.js

        PHP Code:
        define('custom:contact-handler', ['action-handler'], (Dep) => {
            return class extends 
        Dep {

                
        initNewContact() {}

                
        newContact(datae) {
                
                    const 
        attributes = {
                        
        accountIdthis.view.model.get('id'),
                        
        accountNamethis.view.model.get('name'),
                    };

                    
        this.view.getRouter().dispatch('Contact''create', { attributes });

                }

                
        isNewContactVisible() {
                    return 
        true;
                }
            };
        });
        ​ 

        Comment

        • CRM-BE
          Junior Member
          • May 2021
          • 13

          #5
          Works perfectly!
          Thank you very much​.

          Comment

          Working...