Announcement

Collapse
No announcement yet.

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

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

  • 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?​

  • #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


    • #3
      Hello,
      thanks, it works with:​

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

      can the parameter AccoutId be transmitted?​

      Comment


      • #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


        • #5
          Works perfectly!
          Thank you very much​.

          Comment

          Working...
          X