Leads custom field that exists in Account

Hi Gurus,

Is there a way to put a field in the leads module that already exists in the account module.

SugarCRM CE 6.5.22.

For instance, I have a request to insert a custom field in the leads that is the annual revenue of the company. If a put a custom field (_c), then, when the lead is converted I will have to enter the information again in the account part because the account already have a annual revenue field. So, is there a way to reuse the account field in the leads part in a way that, when I convert the lead, the revenue information will be in the account information?

all the best,

Daniel

Parents
  • If you create the same field name (exactly) in Leads, and then copy the convertdefs.php file from modules/Leads/metadata/ into custom/modules/Leads/metadata, adding in your field to the array of account fields, it should display.

  • I cannot create a field with same name because sugar automatically puts the _c in the end of the field name. So, I have the field annual_revenue in account and annual_revenue_c in leads. Different names. When I convert the lead, the information cannot be passed automatically. At least, that is my knowledge about the subject.

  • Hello,

    You are right, Sugar will not copy over the values for different field names. What best you can do is, assign the value by extending view.convertlead.php

    Add, $bean->annual_revenue = $lead->annual_revenue_c;

    inside the loop after this comment > //Handle non-contacts relationships

    Looks like

    //Handle non-contacts relationships

            foreach ($beans as $bean)

            {

                if (!empty($lead))

                {

                    $bean->annual_revenue = $lead->annual_revenue_c;

    .

    .

    .

    .

Reply
  • Hello,

    You are right, Sugar will not copy over the values for different field names. What best you can do is, assign the value by extending view.convertlead.php

    Add, $bean->annual_revenue = $lead->annual_revenue_c;

    inside the loop after this comment > //Handle non-contacts relationships

    Looks like

    //Handle non-contacts relationships

            foreach ($beans as $bean)

            {

                if (!empty($lead))

                {

                    $bean->annual_revenue = $lead->annual_revenue_c;

    .

    .

    .

    .

Children
  • Okay, that didn't seem clear when I read your post. You can go with Hash's suggestion, or, you can also create a custom vardef in Leads to create the "annual_revenue" field exactly the same as accounts, which will do so without the _c.

  • Hi,

    I have this:

    //Handle non-contacts relationships

            foreach ($beans as $bean)

            {

                if (!empty($lead))

                {

                    if (empty($bean->assigned_user_id))

                    {

                        $bean->assigned_user_id = $lead->assigned_user_id;

    Should I put it before or after "if (empty($bean->assigned_user_id))"

    Thanks

  • Hello,

    Yes before that if (empty($bean->assigned_user_id)) statement, I am sorry for being unclear about where to place the code.

  • Thank you.

    but maybe I'm doing something wrong. I did the test with a field that I already have, " industry" as you can see, I have industry_c in leads:

    industry_c.png

    Then I did the relationship the the file view.convertlead.php under public_html/sugarcrm/modules/Leads/views:

    convert_lead.png

    After that I did a quick rebuild. but when I select "convert lead", the industry field is empty:

    industry_empty.png

    Am I missing something here? Sorry if it's a dumb question, but I'm new to sugar and have a lot to learn.

    all the best,

    Daniel

  • Hello Daniel,

    Can you please make sure the dropdown list you are using in Accounts(industry_dom) and Leads modules are same?

    How to check? Admin > Studio > Leads > Fields > industry_c > Dropdown list

    P.S. I tested in v 6.5.18 and your code works fine for me.

  • Hi Hash,

    Yes they are the same:

    industry_c.png

    industry.png

    Any ideas?

  • This is strange! It should work..

    Lets debug using

    $GLOBALS['log']->fatal($lead->industry_c); // add this above your added custom code

    Run it again and see if you have the value in sugarcrm.log

    And along with that, check in database in accounts table with newly created ID if it has value in industry field.

  • Sorry, didn't work

    I put the log line there:

    convert_lead2.png

    Did the repair:

    Repair_1.png

    Repair_2.png

    but the only lines from today in my log are:

    Fri Feb 5 15:42:30 2016 [24445][-none-][FATAL] SECURITY: User authentication for paul.bernard failed

    Fri Feb 5 15:42:30 2016 [24445][-none-][FATAL] FAILED LOGIN:attempts[1] - paul.bernard

    as I canceled the conversion of the lead, my last record in account table is old:

    mysql> select max(date_entered) from accounts;

    +---------------------+

    | max(date_entered)   |

    +---------------------+

    | 2016-01-12 16:25:45 |

    +---------------------+

    1 row in set (0.02 sec)

    mysql> select max(date_modified) from accounts;

    +---------------------+

    | max(date_modified)  |

    +---------------------+

    | 2016-01-12 17:02:16 |

    +---------------------+

    1 row in set (0.00 sec)

    and just to be sure I'm modifying this file:

    public_html/sugarcrm/modules/Leads/views/view.convertlead.php

    and the log I'm looking is:

    public_html/sugarcrm/sugarcrm.log

    all the best,

    Daniel

  • Hello Daniel,

    Can you make sure you dont have custom/modules/Leads/views/view.convertlead.php ?

    If you have, the changes should be made to that file. And if you dont have it, it is always recommended to copy the original file and paste it in custom folder.

  • Hi,

    I didn't have the views folder under /public_html/sugarcrm/custom/modules/Leads/

    now I created and copied the modified file:

    # pwd

    /home/consquest2014/public_html/sugarcrm/custom/modules/Leads/views

    # ls -la

    total 48

    drwxr-sr-x 2 4096 Feb  9 08:43 ./

    drwxr-sr-x 6 4096 Feb  9 08:42 ../

    -rwxr-xr-x 1 38970 Feb  9 08:43 view.convertlead.php*

    convert_lead.png

    I also removed the lines from the original file.

    did a repair, but nothing happened. and still no entries in the log.

    same problem.

    Must be something really dumb that I'm doing. Maybe you could assume that I know nothing and start from scratch, asking me really newbie questions. Maybe I'm missing something that you assume I should know.

    all the best,

    Daniel.