Hello there…
The way you are trying to achieve this is not correct. Also I did not really understood your setup.
First of all I don’t know if you are using a true RELATE field. If you do…DON’T. I was not able to debug it but it does not seem to work like the relationships do.
Instead of using a relate field, create a true custom relationship (if you were using a relate field the relationship will be 1-1
Then Try the following:
class Prepaymentt2
{
function AdvancePayment2($bean, $event, $arguments) //All variables are passed by reference now so no need to do &$focus. Also use $bean
{
$accountbean = BeanFactory::getBean('Accounts',$bean->account_id); // This the account bean related to this one
//...then check what you want in its fields...like $accountbean->billingaddress == "whatever"
To copy the relationship (WHY do you want to do that ? Isn't the two objects already related ???? try
$bean->load_relationship
and then
$bean->RELATIONSHIP_TABLE->add()
}
}
Hope I helped…