AnsweredAssumed Answered

How can I check the number of related records in a before_save logic hook?

Question asked by Francesca Shiekh on Feb 11, 2014
Latest reply on Dec 29, 2016 by Ishani Lad
I have a custom module in a m-1 relationship with opportunities.
I have a sub panel on opportunities and that's the only place that people can create a record (sub panel Create). 
In a before_save hook, what is the best way of finding out if this is the first such record related to the Opportunity? (basically I want to default this custom record to primary if it's the first one to be entered for this particular Opportunity).

Francesca S.
SugarCRM Pro 6.5.15 
on Site LAMP