Announcement

Collapse
No announcement yet.

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

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

  • 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

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

    Comment


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


      • #4
        comma .. ... .

        Comment


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


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

            Comment


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


              • #8
                File permissions

                Comment


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


                  • #10
                    This js file should be accessible in browser (type path in browser address bar)

                    Comment


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

                      #RedirectMatch 403 (?i)/custom

                      which I commented out.

                      Comment

                      Working...
                      X