Announcement

Collapse
No announcement yet.

How to call custom controller actionUpdate function from Email send js

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

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

  • #2
    Hello,


    PHP Code:
    $.ajax({
                        
    url'Account/action/MethodName',
                        
    type'POST'
                        
    dataJSON.stringify(data),
                        
    success: function (data) {
                            if (
    data['status'][0]){
                               ....
                            }else{
                                 
    Espo.Ui.notify('we have problem!''error'2000); 
                            }    
                        }
                    }); 

    Comment


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


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


        Comment

        Working...
        X