filter get related Beans

When using SugarCRM/SuiteCRM it is far better to use the framework which is given to us, however using this can sometimes be harder than you think when you are looking to do some of the similar tasks. here is a slice of code which allows you to filter down related beans, this gets an account bean by id and then allows you to filter using a MySQL where statement to then get the related beans from that.

you can also filter down on the deleted records using a very similar method.

'lhs_field' => 'billing_address_state',
'operator' => '=',
'rhs_value' => 'OH',
$contacts = $account->contacts->getBeans($params);

if(!empty($contacts)) {
foreach($contacts as $contact) {
echo $contact->name."
"; } }