Auto Populate from Flex Relate Field

Hello! I am trying to auto populate from a flex relate field. So far looking at forums and browsing for it, it seems everyone has so far explained how to auto populate from a relate field.

I’ve used this guide for it.

But here is my scenario. I have a custom module called Sample Request. A sample request can be sent to either an Account, Lead, or Contact. And in that sample request page there is an address field for where the sample will be sent to. How do I set it so if I select an Account it will auto populate that linked accounts address, or if I select Contact or Lead it will auto populate the address fields under that choice.

Any help would be appreciated.

I don’t think you can make field definitions conditional and dependant on the parent module. You could however quite easily achieve the intended result through logic hooks. Create a before_save hook that checks for parent_module and fetches data accordingly, filling the address fields in your module. This way however the address wouldn’t be visible on EditView but would be filled as soon as you hit “save”.

Another option would be to query the parent bean on EditView through Javascript.

You might want to reconsider if it’s really necessary to save the address data in different records instead of checking the parent as needed (e.g. when creating dispatch labels or tasks). Unless the data serves a specific purpose, that sounds like redundancy and could cause out-of-sync problems.

You can do it.
You wrote link to post for “relate” field type, but if you use “parent” field type you should “customCode” for this field in editviewdefs.php .I made it and it worked. If I find this code, I write.

Did you ever find this code?

I am looking at an identical issue - copying address data over to my AYU_Funds module based on the setting of a Flex_Relate field which could be either an Account or a Contact


The address fields in Accounts and Contacts have different names (billing_address_… vs primary_address_…) so the field_to_name_array does not work without some kludge to the setup.

Did your code accommodate the different naming conventions?


I think that you can write

  • javascript for select button,
  • php custom code for quick search.