How to create many records from one convert lead

Hello

I would like to store the contact details in a separate module and a separate record for each type. for example, one record for a phone, another record for a home phone, a third record for an Instagram link, and so on. (this called one-to-many relationship for SuiteCRM)
Right now it works for me as a one-to-many relationship between Contacts module and my_custom module.

My question is how can I implement this for leads? I mean, take information from a lead and, when converting a lead, create several records in my_module, each of which is tied to a contact? that is, a one-to-many relationship

Can you not select your lead, and then Actions->Duplicate for each lead and work from there?

@anothermouse
Thanks for quick reply
I would like (and have already configured) to collect information such as contact module, account module, and contact information in the lead.
If I duplicate, then both contacts and accounts will be duplicated too.
I perfectly understand that I most likely will not find a ready-made solution, but maybe I will find good advice or even someone’s best practices of converting a lead into a one-to-many relationship

If you go into Admin->Studio and look at the fields in the Lead Module then you’ll see that the structure includes a fields for contact and accounts information.

If say you wanted to separate out the contacts information, then you’d create an additional relationship. This would be a many to many relationship. (A one to many relationship is a special sub case of many to many relationship). You can then include this in your various layouts and views.

Instead when creating your lead, you select your account/contact from this new relationship, and remove the standard account/contact in the various views. This way, when you duplicate it, you don’t duplicate the contacts and accounts information.

(If you’ve ever done database normalisation, then consider it to be a form of that)

@anothermouse
thanks for your help
but still I would like to try to implement my first idea.
I hope to find some tips on how to do this.
Right now, I’m thinking of making a custom pрp code that will write one-to-many directly to the database, but I would like to know how I can get the current contact ID of a converting lead. To add a new one-to-many relationship to the current contact
for example, if I find current contact ID, then I can create custom SQL query to add a new record in my_module_contact (one-to-many relationship table)
of course it all looks out of suitecrm style, but I would like to try

For that you will need logichooks.

Use beans to create records on any module you want.
Check this sample it still applies to SuiteCRM:

https://community.sugarcrm.com/thread/21744

Thanks,

AlxGr

@suitecrm_developer
Hello
really wanted to know if you faced such a task as adding one-to-many relationships through converting leads ?

Thanks

Hi,
You can add a related field into your custom module, for your case this field should be Contact field.
Now while saving the converted lead, you can add your custom code to save the entries into this new custom module.

You can file a file being used while converting a lead here

modules\Leads\views\view.convertlead.php

(or in Custom folder as well, you need to first check the custom folder.)

In this file you can modify the function handleSave() function to do the code.

Thanks

Thanks for your reply
I didn’t quite understand how I can do this

  1. Should I create relate field in my custom_module with Contact module(or lead module)
  2. Could you suggest some code example I should use In handleSave() ?

as an example I would like to have duplicate fields for home and work. For example home phone and work phone. So that I can fill in both fields in the lead and it will automatically convert to home phone record in my_custom_module like a new one-to-many relationship, and work phone field would be a separate new one-to-many relationship record in my_custom_module
I hope I was able to convey my point of view

Thanks

@ashish
Hello

Maybe you’ve met something like that?
creating one-to-many relationships from separate field


based on the screenshot, for example, I fill in all the fields and from the fields Channel name + Channel type + Usage type + home address a separate record is created in my custom module(like one-to-many relationship with Contacts Module), and from the fields Channel name + Channel type + Usage type + work address a new record is created in my custom module (like one-to-many relationship with Contacts Module) and so on