I stumbled on this today and thought I'd share.
Ever wanted to copy related records when using the Copy action from Record View?
It's simple just add a vardef extension!
For example, I have a custom oppp_OpportunityProducts module on Opportunities.
When copying an Opportunity I also want to copy the OpportunityProducts
I added the following:
$dictionary['Opportunity']['after_create'] = array(
'copy_rel_from' => array (
'oppp_opportunity_products_opportunities' is the link from Opportunities to oppp_OpportunityProducts.
Want to copy more related records? Simply add more link names to the array.
Now when the Opp is copied, the products are copied with it.
(Tested in SugarCRM 7.8 Professional)
NB: beware of cardinality! If your relationship is 1:M (e.g. each product can only be related to one opportunity only) the product will MOVE to the new Opportunity record and will disappear from the original!