make lead read only after lead was converted to opportunity or contact

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ruslan
    Senior Member
    • Aug 2014
    • 102

    make lead read only after lead was converted to opportunity or contact

    Hi,
    if it is possible to make the lead read only when the lead is converted to opportunity or contact?
    ​or if lead status change to "dead" for example.

    2. when you change status to some entity the system create note and status background is always "green".
    ​how can we set "red" color for "dead" status for example?

    Thanks
  • yuri
    Member
    • Mar 2014
    • 8455

    #2
    Hi

    1. It can be done on client side.
    1) specify custom model class in metadata clientDefs >> Lead
    "model": "Custom:Models.Lead"
    2) create client/custom/src/models/lead.js
    PHP Code:
    Espo.define('Custom:Models.Lead', 'Model', function (Dep) {
        
        return Dep.extend({    
    
            isEditable: function () {
                if (!this.isNew()) {
                    if (this.get('status') == 'Converted') {
                        return false;
                    }
                }
                return true;
            },
    
        });
    }); 
    
    2. Please provide an example. Just tried to change lead status to Dead and red label appeared in the stream.
    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

    • Ruslan
      Senior Member
      • Aug 2014
      • 102

      #3
      Hi Yuri,
      1. i have add "model": "Custom:Models.Lead" to application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json
      its look like this:
      Code:
         "model": "Custom:Models.Lead"
         "controller": "Crm:Controllers.Lead",
         "views":{
            "detail":"Crm:Lead.Detail"
         },
      i created the js file as you write. then i clear all the cache.
      then i create "test lead" and when i wanted to "convert " the lead the "convert button disappeared" when i removed the code "model": "Custom:Models.Lead" the convert button was appeared.
      i also check the lead i was converted before and it still was editable and to read only.

      2. you are the red label is appear for dead status, my mistake.
      ​but it will good to know how can we set label color based on custom status.
      ​for example for task or projects (task cannot be completed or project cannot be done ertc...)

      Thanks!

      Comment

      • yuri
        Member
        • Mar 2014
        • 8455

        #4
        comma .. ... .
        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

        • Ruslan
          Senior Member
          • Aug 2014
          • 102

          #5
          Yuri,
          i did this before. i also try to put the code at the bottom of the code and that's why the "model": "Custom:Models.Lead" without the "comma".
          the problem is when you put code with comma "model": "Custom:Models.Lead", the "lead" link in the menu stop working.
          you can click on the menu link but the leads page(view) not showing.

          what do you think the problem here?

          Thanks

          Comment

          • yuri
            Member
            • Mar 2014
            • 8455

            #6
            PHP Code:
                 "model": "Custom:Models.Lead",    "controller": "Crm:Controllers.Lead",    "views":{       "detail":"Crm:Lead.Detail"    } 
            
            Clear Cache. The file client/custom/src/models/lead.js should exists. See console for errors (F12 in browser)
            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

            • Ruslan
              Senior Member
              • Aug 2014
              • 102

              #7
              something really strange!
              this js file is in the folder: client/custom/src/models/lead.js

              maybe the problem that i am using espocrm as sub domain and not main domain?

              i get this error:

              Failed to load resource: the server responded with a status of 403 (Forbidden) http://myweb.com/client/custom/src/m...=1410454234161
              Uncaught Error: Could not load file 'client/custom/src/models/lead.js' espo.min.js?r=1406817452099:14path.pathsBeingLoade d.$.ajax.error espo.min.js?r=1406817452099:14l espo.min.js?r=1406817452099:3c.fireWith espo.min.js?r=1406817452099:3k espo.min.js?r=1406817452099:4(anonymous function) espo.min.js?r=1406817452099:4

              Comment

              • yuri
                Member
                • Mar 2014
                • 8455

                #8
                File permissions
                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

                • Ruslan
                  Senior Member
                  • Aug 2014
                  • 102

                  #9
                  Hi,
                  i have set the file permissions to 777 and still the same error. i also check all the folders to the file and all have 755.

                  Comment

                  • yuri
                    Member
                    • Mar 2014
                    • 8455

                    #10
                    This js file should be accessible in browser (type path in browser address bar)
                    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

                    • Ruslan
                      Senior Member
                      • Aug 2014
                      • 102

                      #11
                      The issue was caused due to this .htaccess rule:

                      #RedirectMatch 403 (?i)/custom

                      which I commented out.

                      Comment

                      Working...