You may recall seeing this field in the various activity modules in Sugar:
This is what’s known as the “Flex Relate” field, which allows you to relate a record to one in a different module that you specify. This allows you to create a relationship where the target entity is flexible, which allows you to represent all sorts of business logic clearly. A great example of this the various activity entities in the app ( Calls, Meetings, Tasks ), which make it so you can relate the activity to one of many different record types.
The only downside of this field, is there’s no good way to build it using Module Builder or Studio ( or least in a very useful way ). However, it’s a pretty easy code customization you can do which is upgrade-safe. Let’s look at how.
We’ll assume we made a new custom module via Module Builder named test_flexparent, which will have a flex relate field that can relate to either the Contacts or Leads module. To do this, we must define the fields and relationships which will be needed to make this happen; we can do this by adding the file custom/Extension/modules/test_flexparent/Ext/Vardefs/flexrelate.php with the following contents:
There are three parts to this file. The first part defines the three fields we have added to manage the relationship: parent_name, parent_id, and parent_type. We next add two link fields which will correspond to the relationships we’ll add for the links between this module and contacts and leads. Finally, we define the actual relationships themselves.
One more thing we need to do is add in the language files which specify the field’s string name as well as the dropdown. You can do this by adding a file named custom/Extension/application/Ext/Language/en_us.flexrelate.php.
Now after a Repair Relationships and a Quick Rebuild and Repair, the field will be available and you can add it to the module’s various views.