AnsweredAssumed Answered

How do I use multiple flex relate fields in a custom module?

Question asked by Alx on Aug 8, 2014

I am using Sugar 7.2.0 PRO.

I need to create a custom module with two flex relate fields.
Unfortunately, the Studio and the Module Builder don't allow more than one Flex Relate field (I reckon this is due to the 'parent_type' and 'parent_id' field names being hard-coded).

So I tried to create my own field type: I copied clients/base/fields/parent into custom/clients/base/fields/gauche_parent and replaced every occurence of 'parent_name' by 'gauche_parent_name' and every occurence of 'parent_id' by 'gauche_parent_id'.
Then I added my field definitions in custom/Extension/modules/dotb1_role/Ext/Vardefs/ :

'comment' => 'The ID of the parent Sugar object identified by parent_type'
'name'=> 'gauche_parent_name',
'parent_type'=>'dotb_role_parent_type_display' ,
'options'=> 'dotb_role_parent_type_display',
'studio' => true,

//'type' => 'gauche_parent_type',
'type' => 'parent_type',
'options'=> 'dotb_role_parent_type_display',
'studio' => array('wirelesslistview'=>false),

I ran a Quick Repair And Rebuild and executed the suggested SQL queries.

Unfortunately, this is not working as expected: the field displays correctly in edit mode (I can choose the module from a dropdown and select a record) but, as soon as I hit the Save button, it is shown as if it were empty.

I have two options:
- I can either make this custom field type work (but I admit I don't know how to accomplish that)
- or I can find a way to add a second Flex Relate to my module. I saw that in 2012 SugarCRM's Community Manager John Mertic said it was possible through code (, but I couldn't find how.

Could anyone please point me in the right direction?