query for fetching address from address tab of employee detail form (need urgent help)

Hi,

I need to fetch address fields like street,street no.,country,zipcode etc from address tab of employee form for the employee which i have selected on overview tab. i have written a query in my reports display method as :

display str AddrComplement()
{
str addr;
str street;
str Number;
str Complement;
str Zipcode;
str City;
str State;
str Country;
Address address;
DirPartyTable DirParty;
DirPartyAddressRelationship Relationship;
DirPartyAddressRelationshipMapping Mapping;

;
select EmplTable where EmplTable.PartyId == DirParty.PartyId
join Relationship where Relationship.PartyId == DirPartyTable.PartyId && Relationship.RecId == DirParty.RecId
join Mapping where Mapping.RecId == Relationship.RecId
join address where address.RecId == Mapping.AddressRecId && address.dataAreaId == Mapping.RefCompanyId;

if(DirParty.RecId)

{
select Address
where Address.AddrRecId == DirParty.RecId
&& Address.type == AddressType::Home;
if(address.RecId)

{

addr = Address.Name;
street = Address.Street;
Number = Address.AddressNumber;
Complement = Address.AddressComplement;
Zipcode = Address.ZipCode;
City = Address.City;
State = Address.State;
Country = Address.Country;

}

}

return strfmt("%1 %2 \n %3 %4 \n %5 \n %6 %7 \n %8 ",addr,street,Number,Complement,City,State,Zipcode,Country );
}

But i am not able to retrieve the address corr5ectly.kindly help me with query.

Thanks & Regards,

Kalpna

This is definitely wrong:

where Mapping.RecId == Relationship.RecId

I think it should be:

where mapping.PartyAddressRelationshipMapping == relationship.RecId

Also, you shouldn’t have there the following condition:

&& Relationship.RecId == DirParty.RecId