Mapping a target website_c field to the lead website field when converting a target to a lead


I have just started using Suite CRM and would like to map a website_c field in a target (called a prospect in the backend I think) to the website field in lead, which already exists. Because the prospect field is a custom field (it has _c after the name), and therefore the field name does not match with the fieldname in the lead, so it does not auto convert. I have found some help files about how to convert a custom field from a lead, but not to one, and the instructions don’t seem to be relevant for a target/prospect. This is the help I found for converting a lead to a contact:

Can anyone please help me to figure out where I need to modify code to get these fields mapping properly when I convert from a target to a lead?

Thank you.


I think it’s happening here

if you fix it with something generic enough, we can put it into core code. Otherwise, it will be hard to make your changes upgrade-safe…

Thank you pgr.

That’s exactly what I needed. I have updated my own CRM code by copying the modules/Leads/controller.php file to /custom/modules/Leads/controller.php and adding the below changes.

I think the below code would be generic enough to work for everyone though. It basically checks for any matches from a custom field name (ending in _c) to a standard field name (not ending in _c) for any fields not already mapped with a direct match in name when converting a target to a lead:

so at line 72 in modules/Leads/controller.php, where it has:

if (isset($this->bean->field_defs[$key])) {
    $this->bean->$key = $prospect->$key;

I have added afterwards the following:

//check for matches from custom fields to non-custom fields
elseif(substr($key, strlen($key)-2) == "_c")
    $standardfield_c = substr($key, 0, -2);
        $this->bean->$standardfield_c = $prospect->$key;

I hope this helps others.

What is the process for submitting this for consideration in core code?


Jess Gramp

1 Like

So you would need to

  1. clone the SuiteCRM repo. This way you get a copy of it in your own user space.

  2. Your change is going into the “hotfix-7.10.x” branch, since it is technically a bug fix, not a new feature. So you would start a new branch on your repo, from under the “hotfix-7.10.x” branch, and call the new branch for example “fix-conversions”.

  3. Push your changes into that branch.

  4. Start a Pull Request from your new branch into SalesAgility’s “hotfix-7.10.x” branch.

There is a lot of GitHub documentation for all these steps, but if you run into problems just ask for our help, don’t hesitate.

Further reading:

Thanks. I’ll get on to this asap.

1 Like

I have submitted a pull request for these changes to the “hotfix-7.10.x” branch as suggested. Thanks again for the detailed info.

1 Like

Thank you for the contribution!

1 Like

Here is the link for reference:

I’ll ask if somebody from the team can have a look. Thanks