Convert lead -> mapping related fields ?

Hey there, 2 questions for lead convertion :

1: How can I map related fields ? I’ve tried this in view.convertlead.php but its not work:

if ($module == 'Accounts')
{
$beans[$module]->coop_cooperative_accounts_1_name = $lead->coop_cooperative_leads_1_name;
}

For normal fields it work great like in this topic :

https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/13524-converting-leads-with-custom-fields-then-how-to-copy-the-leads-custom-fields-into-the-new-accounts

2: I have an important dropdown account type (Provider OR Client) in account.

How can I display it in the convertlead view ?

I have a lot of code behind this dropdown, I need the user to complete this dropdown.
For now its empty when I convert a lead.

Thanks in advance !

  1. Look for some code that uses “load_relationship” and use that system to first traverse the relationship, then change the field

  2. I don’t know the answer. But does it need to be filled in the moment of conversion? Why not before, in the Lead, and then it’s just copied directly to the converted record like any other field?

Thanks for ur fast answer !

tried this :


$beans[$module]->load_relationship( 'coop_cooperative_accounts_1' ) = $lead->load_relationship( 'coop_cooperative_leads_1' );

Got this badass error :

Fatal error: Can’t use method return value in write context

For the 2nd, thanks a lot, easy but I think I will save time by doing this.

That is not correct at all, sorry :slight_smile:

Please study this chapter, it will be very useful to you:

https://docs.suitecrm.com/developer/working-with-beans/

You have an example of load_relationship there.

Do you know how can I debug this file ? Without debuging its rly hard …

That my latest try :


                                        $coopProspects = $lead->bean->coop_cooperative_leads_1->getBeans();

					$coopProspect = reset($coopProspects);

					
					echo($coopProspect);

					$coopComptes = $beans[$module]->load_relationship('coop_cooperative_accounts_1');

					$coopCompte = $coopCompte->contacts_accounts_1_name;
					
					$beans[$module]->load_relationship('coop_cooperative_accounts_1');
					$beans[$module]->coop_cooperative_accounts_1->add($coopProspect)

You can setup XDEBUG in your web server for PHP debugging, see any online tutorial.

Get an IDE for it and start debugging properly, sometimes it is tough to set up but the gains are enormous, your productivity will be multiplied, and also the reliability of your code.

Remember you can test the return values of all those functions to see if they are returning what you expect, and not “null” or something else.

1 Like

Okay I’ve made it !

Here is the code if anyone is in my case :



					$lead->load_relationship('coop_cooperative_leads_1');
					$coopProspects = $lead->coop_cooperative_leads_1->getBeans();
					$coopProspect = reset($coopProspects);


					$beans[$module]->load_relationship('coop_cooperative_accounts_1');
					$beans[$module]->coop_cooperative_accounts_1->add($coopProspect);

Thanks PGR, as always !

2 Likes

Thank you, just used this to map a relate field from a lead to a contact!

1 Like