lunedì 6 febbraio 2017

AX 2012 - Recuperare l'indirizzo del cliente per tipo

Con questo semplice job possiamo recuperare l'indirizzo del cliente ricercando per tipo (Fatturazione, spedizione etc..)

 static void getCustomerAddressType(Args _args)  
 {  
    DirPartyLocation            partyLocation;
    DirPartyLocationRole        partyLocationRole;
    LogisticsLocation           location;
    LogisticsLocationRole       locationRole;
    LogisticsPostalAddress      postalAddress;
    CustTable                   custTable;
    LogisticsLocationRoleType   type;

    custTable   = CustTable::find("CLI0046");
    type        = LogisticsLocationRoleType::Business;

    select firstonly postalAddress
        exists join location
        where location.RecId == postalAddress.Location
        exists join locationRole
        where locationRole.Type  == type
        exists join partyLocation
        where
        partyLocation.Location == location.RecId &&
        partyLocation.Party == custTable.party
        exists join partyLocationRole
        where partyLocationRole.PartyLocation == partyLocation.RecId &&
        partyLocationRole.LocationRole == locationRole.RecId;

    info(postalAddress.Address);
 }  


Nessun commento:

Posta un commento