Hi andy, that blog post you linked was my salvation when I had to do something similar a few months ago.
Even though you did an excellent job laying out everything in detail, I still found it difficult to apply to my case. Learning by example isn’t always enough, sometimes the logic being the example is needed.
Even though my code is working now, I still don’t fully understand it and would like to ask you if you could please explain this part a little better:
In the vardefs, we define three fields, e_date_cancelled, event_cancelled and cancelled_id. It’s the first one that is unclear to me:
$dictionary['Contact']['fields']['e_date_cancelled'] =
array (
'name' => 'e_date_cancelled',
'rname' => 'id',
'relationship_fields'=>array('id' => 'cancelled_id', 'date_cancelled' => 'event_cancelled'),
'type' => 'relate',
(....)
If I understand correctly, this is a sort of “virtual field”, not stored in the database, is that right? Why is this needed?
Then those fields being mapped in relationship_fields? They seem to be mapping the stuff in the metadata for the relationship (‘id’ and ‘date_cancelled’) to the stuff that comes next in these vardefs (a dictionary entry for ‘cancelled_id’ and ‘event_cancelled’). Again, why?
Finally, when we get to the subpanel definitions, it seems we need to include all three fields there (e_date_cancelled, event_cancelled and cancelled_id), but leave them as ‘query_only’ if we don’t intend to show them to the user, or else give them a label and a width and show them.
Can you help with some more insights? For me this is a basic need when data modelling, using fields in relationships… and it is still way too difficult to do in SuiteCRM…