How to call custom controller actionUpdate function from Email send js

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manosingh
    Member
    • Apr 2019
    • 62

    How to call custom controller actionUpdate function from Email send js

    There is a mail compose function inside the espo crm , and i'm trying to update email_status of the related entity once after sending the mail.

    \client\src\views\email\record\compose.js

    Inside this file

    send: function () {

    ajax call to custom controller

    }

    I need to make a custom controller call , how to do ?

    I tried to use Entity name

    $.ajax({
    url: "MyEntityName",
    type: "post",
    data:,
    success: function (response) {

    },
    error: function(jqXHR, textStatus, errorThrown) {
    console.log(textStatus, errorThrown);
    }
    });

    This ajax calls the actionCreate function , But actually i need to call actionUpdate function with the Entity id , so i tried this way

    $.ajax({
    url: "MyEntityName/myentityid",
    type: "post",
    data:,
    success: function (response) {

    },
    error: function(jqXHR, textStatus, errorThrown) {
    console.log(textStatus, errorThrown);
    }
    });


    The above ajax call shows 404 not found , error , how to solve this issue , any help is appreciated , Thanks in advance

    is it good to use custom controller function ? if so please let me know how to call custom controller function.


    Last edited by manosingh; 08-01-2019, 11:45 AM.
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hello,


    PHP Code:
    $.ajax({
                        url: 'Account/action/MethodName',
                        type: 'POST', 
                        data: JSON.stringify(data),
                        success: function (data) {
                            if (data['status'][0]){
                               ....
                            }else{
                                 Espo.Ui.notify('we have problem!', 'error', 2000); 
                            }    
                        }
                    }); 
    
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • manosingh
      Member
      • Apr 2019
      • 62

      #3
      Hi item thanks for the response , it works fine , i can't able to get the data from ajax inside my controller function

      I tried to get data using the following

      $_GET['mydata'];
      $_POST['mydata'];
      $_REQUES['mydata'];

      but this 3 functions are not getting the data from ajax. is there any other way to pass and get data inside controller function , please let me know thanks in advance.

      Comment

      • item
        Active Community Member
        • Mar 2017
        • 1476

        #4
        hello,
        I have not big skill but I use this :

        in controller :

        PHP Code:
            public function actionMethodeName($params, $data, $request)
            {
                $entity = $this->getRecordService()->read($data->id);
                //return $this->getRecordService()->getMyService($entity, $data->id);
        
            } 
        
        have a look to :
        application/espo/crm/modules/controller/...


        If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

        Comment

        Working...