Creating a custom view/controller/route.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thodr4
    Junior Member
    • Nov 2019
    • 3

    Creating a custom view/controller/route.

    Hello,
    I am trying to make a custom duplicate check tool for my EspoCRM backend. I have followed the steps in the docs(https://docs.espocrm.com/development/api-action/):
    • Created custom/Espo/Custom/Controllers/MyController.php with the example specified in the docs:
    Code:
    <?php
    
    namespace Espo\Custom\Controllers;
    
    class MyController extends \Espo\Core\Controllers\Base
    {
        public function getActionDoSomething($params, $data, $request) {
            die("test");
        }
    
        public function postActionHelloWorld($params, $data, $request) {
            $name = $params['name']; // 'someName'
        }
    }
    • Created custom/Espo/Custom/Resources/routes.json with the example specified in the docs:
    Code:
    [
        {
            "route": "/Hello/test/:id",
            "method": "get",
            "params": {
                "controller": "MyController",
                "action": "doSomething",
                "id": ":id"
            }
        },
        {
            "route": "/HelloWorld/:name",
            "method": "post",
            "params": {
                "controller": "MyController",
                "action": "helloWorld",
                "name": ":name"
            }
        }
    ]
    When i visit <crm_url>/#Hello/test/1 i get a 404. Im expecting to see 'test'. Did i overlook something in the docs? I just cant get it to work. Any clues?

    Thanks,
    Thomas
  • yuri
    Member
    • Mar 2014
    • 8442

    #2
    Hi,

    Did you clear cache?
    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

    • thodr4
      Junior Member
      • Nov 2019
      • 3

      #3
      Yes, and rebuild it too!

      Comment

      • yuri
        Member
        • Mar 2014
        • 8442

        #4
        You created a backend API action. It is available by URL api/v1/Hello/test/1.

        Frontend has another framework. See https://docs.espocrm.com/development...nd/controller/.
        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

        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #5
          hi thodr4, how did you go? Did you manage to get it to work?

          This thread might be of interest to you: https://forum.espocrm.com/forum/gene...icate-checking

          I'm trying to create a duplicate check too but no luck at the moment.

          Comment

          Working...