Auto Populate related fields

Hi

Im using SuiteCrm version 7.11.15.

I have a related field on my Opportunities module that picks a Contact from the contacts module. I also want to get this contacts email addrs and cell phone number which I have created as fields on the Opportunities module.

So I want to chose a contact(Relate field) and have their email and cell number auto populated on my Opportunities module fields.

I tried doing this via Workflow with adding relationship but could not get this to work.

Any help would be appreciated.

Regards
Nzi

Try a before save logic hook then.


Thanks,

BrozTechnologies

@nzi200779
You should add to the field which type is “relate” to Contacts in file “module/Opportunities/metadata/editviewdefs.php” next code:

...
'panels' => array (
...
    'lbl_...' => array (
...
        <number>=> array (
            <number>=> array (
                'name' => '<your_field_name_of_relate_to_Contacts>',
                 'displayParams' => array (
                     'field_to_name_array'=> array(
                         'name' => '<your_field_name_of_relate_to_Contacts>',
                         'id' => '<your_field_id_of_relate>',
                         '<field1_of_Contacts_module>' => '<field1_of_Opportunities_module>',
                         '<field2_of_Contacts_module>' => '<field2_of_Opportunities_module>',
                         '<field3_of_Contacts_module>' => '<field3_of_Opportunities_module>',
                     ),
                 ),
            ),
        ),
...
    ),
...
),
...

P.S. If you use Studio your file “custom/module/Opportunities/metadata/editviewdefs.php”

Hi p.konetskiy

I tried updating as suggested , but no luck. Please check the file attached to see if I did it correctly :slight_smile:
THanks
editviewdefs.zip (957 Bytes)

No, You shouldn’t copy my code because it’s the template. I changed code for you but I don’t see you system and know name of one field - “???”. It is field which type ‘id’ and it relate with job_contact_c.

  • before:
          array (
            'name' => 'job_contact_c',
            'studio' => 'visible',
            'label' => 'LBL_JOB_CONTACT',
          ),
  • after
          array (
            'name' => 'job_contact_c',
            'studio' => 'visible',
            'displayParams' => array (
                'field_to_name_array'=> array(
                    'name' => 'job_contact_c',
                    'id' => '???',
                    'email1' => 'cont_email_c',
                    'phone_mobile' => 'cont_mobile_c',
                    'phone_work' => 'cont_office_c',
                ),
            ),
            'label' => 'LBL_JOB_CONTACT',
          ),