one to many relationship from converting lead

Hello SugarCRM community

I would like to add new one-to-many relationship from the lead page to my custom module.
As I understand it, I have to use a logical hook, but I cannot implement it.
Could you help me?
I have a lot of difficulties with this, for example, how can I get the current ID? or is it not needed at all
Here is an example of my use case:
I would like to have on the lead page such fields as contact information with two prefixes home and work.
And so that the field with the home prefix after conversion of the lead is automatically recorded as a record of a one-to-many relationship in my custom module. And fields with a worker prefix will be created in another one-to-many relationship record.
I would like a new record to be created for each prefix.
For example, for each fields, home mobile, work mobile, instagram, email, work email, so that all these fields would be as separate records in the subpanel of my custom module. (one-to-many relationship)

I hope I was able to explain it correctly.
I'm not very good at this, I wanted to ask you for advice, maybe someone came across a similar one and could share an example of my code that I could change

Thanks

  • Hi Dima,

    You do not need a logic hook to add a new relationship. You can create a one-to-many relationship in two places - either in Module Builder when you first design your custom module (it will be m:1 then), or in Studio after the custom module has been deployed/installed into your environment. It sounds like you may have already created the relationship, but for reference, the guide is here: https://support.sugarcrm.com/Knowledge_Base/Studio_and_Module_Builder/Understanding_Relationship_Creation_Options/#Creating_Relationships

    Let's move into getting data into this custom module.

    It sounds like each row of this custom module represents another piece of contact information, e.g.

    id field value
    abc home (012) 345 678
    def mobile (012) 678 912
    ghi work (013) 294 103

    You can populate data within the custom module using SugarBPM (requires Ent/Sell/Serve):

    1. Create a new process definition based upon the Leads module, triggering upon new records
    2. Using the "Add Related Record" action, select your custom module
    3. For the 'value' field (or however you've called it), use the Field Selector to select the corresponding data from the Leads module.

    Some tips on making this efficient:

    • You will need one of these "Add Related Record" actions for each piece of contact information you're tracking.
    • You will likely want an exclusive gateway in front of each of these actions to assess whether you need to add a related record or not (based upon whether that field contains valid data in the Leads module - non-empty being a good start!)
    • You are encouraged to make the very first step after the process def triggers, a "Wait 1 min" activity, so that all record creation is queued in the background and does not have any impact upon performance.

    All done without a single line of code - good luck!

    Adam

  • Hi Adam

    Thanks for your reply

    I think this is almost what you need

    but I would like to ask you something else

    How can I set up automatic creation of relationships from my fields after lead conversion (Converting lead)?

    Example, I create a lead and fill in all the fields. Next, I convert the lead and get a new contact and  new account (they have relationship 1-to-2 )


    But how can I make sure that at this step, when converting a lead, new relationships 1-to-2 are created in my custom module and attached to the Contact created from the lead?

  • Hi ,

    If I've understood right, your custom module has m:1 to Leads, as well as m:1 to Contacts. The above solution covers you for Leads (original question), but you're also keen on ensuring that when Contacts are created via the lead conversion process, that these same types of records are created.

    Can I ask a question first: let's suppose you already have a relationship with the company, Acme Inc, but meet somebody new there, Clint. Clint gives you his business card, so now you've got his phone number, email, LinkedIn etc. When you go to the CRM, do you create him as a Contact attached to the company Acme Inc?

    If so, would you want the records in your custom module populated?

    Without knowing any more about your business, I would normally say yes to both those questions.

    And if the answer is yes, then the process def you make will be just like the one you made for Leads, except it will be for the module Contacts, and be triggered on Contact creation there too.

    I'd love to understand a bit more about what this custom module is for. As I typed this, I realised you may want to consider the scenario of Leads/Contacts being updated and additional data being added, or amended (more workflows).

  • Thanks for trying to help me

    I would like to share an example of how I would like to use it.
    When I find a new contact, I want to fill in all the information about him in one place in the lead.

    And so that after the conversion of the lead, all information goes into 3 modules, into contacts, accounts and Channels module. Channels module stores all contact information, and each method of communication is a separate record that is associated with a contact (1-to-many relationship).

    Please see screen 1. This is how I can fill information

    and please see screen 2. this is how I currently have placed Channels in Contacts module

    I hope I could explain what I want


    I would like all information from Facebook, Instagram, Phone Numbers.... fields to be automatically attached to a subpanel to the created contact after converting a lead (where each fields = separate records)

  • hi
    From the screenshots it looks like you're not using SugarCRM but SUiteCRM instead?

    Therefore probably best to ask on their community forum as features are not equal to SugarCRM.

    .

    CRM Business Consultant

  • HI

    right, it's suitecrm but they are very similar,

    I was already looking for a solution on suitecrm forum and decided to try to find advice here.

    I originally thought I would need logical hooks but our advice to use SugarBPM seems to help me.
    In any case, if my question can be solved with SugarBPM then I would switch to sugarcrm, this is not a problem

    could you tell me if my question works in sugarcrm?

  • Hi , thank you for sharing the screenshots. It does explain it a little better. I can confirm that SugarBPM can be used on the Contacts module exactly as you would on the Leads module. 

    Initially, I would not recommend adding any additional conditions to the process def, so that you can see it bringing in data from both lead conversion, as well as other scenarios.

  • Hello

    I created defined that take data from my field and make record in lead subpanel. So right now when I do converting lead I don't have this record in my subpanel in created Contacts too(.

    Have you any idea or tips how can I automatically transfer all records from Lead->subpanel to created from converting leads Conntact->subpannel

  • Hi Dima,

    If you create a process def which is the same type of process, but is just for Contacts, you'll get the same result (of records in the subpanel)... but I understand that that isn't "transferring" records.

    So to confirm - I understand that you want to remove the records from the Leads->Subpanel as part of the conversion process?

    If so, you'll need a logic hook to remove those records too.

    Regards,

    Adam