validate vendor address in axapta 2012

hi all,

I was trying to validate whether user have entered atleast one address when creating vendor master in axapta 2012.

I have wrtitten the below code in write method of datasource(VendTable). but it is allowing to save the record even when there is no address entered for the vendor created.

Select dirPartyPostalAddressView where dirPartyPostalAddressView .party == vendTable.Party;

if (! dirPartyPostalAddressView )

error(“Address does not exist for vendor”);

any help is highly appreciated…

thanks in advance

any help me on this?

in validate write of datasource level try this code

if (! dirPartyPostalAddressView )

{

error(“Address does not exist for vendor”);

return flase;

}

Thanks for ur update

yes i did. its validating but it allows me to close the form without address [:(]

my code as below under “validatewrite”

boolean ret;

DirPartyPostalAddressView postaladdressview;

select firstOnly postaladdressview where postaladdressview.Party == vendTable.Party;

if (!postaladdressview)
{
ret = false
error(‘Address does not exist for vendor’);
}

ret = super();
ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
if (ret)
{
ret = partyForm.validateWrite();
}
return ret;

its working.

i did the same validation in “canClose” method.

thanks for all ur support