Pages

Banner 468 x 60px

 

Friday, November 17, 2017

Get Address, phone using x++

0 comments
Get Address, phone using x++ :


    InventJournalTransHeaderTmp.Address             = VendTable::find(inventJournalTable.VendAccount).postalAddress().Address;
    InventJournalTransHeaderTmp.Phone               = vendTable::find(inventJournalTable.VendAccount).phone();

    Contact         = ContactPerson::find(VendTable::find(_getRecordVendPurchOrderJour.OrderAccount).ContactPersonId).personName();
    _Phone          = ContactPerson::find(VendTable::find(_getRecordVendPurchOrderJour.OrderAccount).ContactPersonId).phone();

    // dari company
    purchReqTmp.CompanyName             =   CompanyInfo::find().Name;
    purchReqTmp.PersonnelNumber         =   HcmWorker::find(purchReqLineHistory.Requisitioner).name();
    purchReqTmp.CompanyAddress          =   CompanyInfo::find().postalAddress().Address;

// ATAU

public boolean fetch()
{
    boolean         ret = true;
    Query           _Query = new Query(this.query());
    QueryRun        _QueryRun;
    PurchTable      _Purchtable;
    PurchLine       _PurchLine;
    PurchReqTable   _PurchReqTable;
    VendTable       _VendTable;
    LogisticsElectronicAddress  _LogisticsElectronicAddress;
    ;

    _Query.dataSourceTable(tablenum(VendPurchOrderJour)).addRange(fieldNum(VendPurchOrderJour, PurchId)).value

(_getRecordVendPurchOrderJour.PurchId);
    _Query.dataSourceTable(tableNum(VendPurchOrderJour)).addRange(fieldNum(VendPurchOrderJour, PurchOrderDocNum)).value

(_getRecordVendPurchOrderJour.PurchOrderDocNum);
    _QueryRun = new QueryRun(_Query);

    while(_QueryRun.next())
    {
        if(_QueryRun.changed(tableNum(VendPurchOrderJour)))
        {
            _getRecordVendPurchOrderJour = _QueryRun.get(tableNum(VendPurchOrderJour));
                No_PO           = _getRecordVendPurchOrderJour.PurchId;
                Supplier_Code   = PurchTable::find(_getRecordVendPurchOrderJour.PurchId).OrderAccount;
                Date_PO         = PurchTable::find(_getRecordVendPurchOrderJour.PurchId).DeliveryDate;
                //Ref_No          =
                //Date_Ref        =
                _VendName       = VendTable::find(_getRecordVendPurchOrderJour.OrderAccount).name();
                Address         = VendTable::find(_getRecordVendPurchOrderJour.OrderAccount).postalAddress().Address;
                Contact         = VendTable::find(_getRecordVendPurchOrderJour.OrderAccount).ContactPerson().phone();
                _Phone          = VendTable::find(_getRecordVendPurchOrderJour.OrderAccount).phone();           
                select _VendTable where _VendTable.AccountNum    == _getRecordVendPurchOrderJour.OrderAccount;
                Contact         = DirParty::primaryElectronicAddress(_VendTable.Party,

LogisticsElectronicAddressMethodType::Phone).Description;
           
                Name_Ship_To    = CompanyInfo::find().Name;
                Address_Ship_To = CompanyInfo::find().postalAddress().Address;
                Contact_Ship_To = DirParty::primaryElectronicAddress(CompanyInfo::find().RecId,

LogisticsElectronicAddressMethodType::Phone).Description;
                Phone_Ship_To   = CompanyInfo::find().phone();
            element.send(_getRecordVendPurchOrderJour);
        }


        if(_QueryRun.changed(tableNum(PurchTable)))
        {
            _Purchtable = _QueryRun.get(tableNum(Purchtable));

            select _PurchLine where _PurchLine.PurchId == _Purchtable.PurchId;
            select _PurchReqTable where _PurchReqTable.PurchReqId == _PurchLine.PurchReqId;

            Indent_Date = _PurchReqTable.RequiredDate;
            Indent_No   = PurchLine::find(_Purchtable.PurchId).PurchReqId;
            Description = PurchLine::find(_Purchtable.PurchId).itemName();
            Quantity    = PurchLine::find(_Purchtable.PurchId).PurchQty;
            Amount      = PurchLine::find(_Purchtable.PurchId).BITAmountPOImport;

            Total_Value                     += Amount;
            Final_payment                   = PurchLine::find(_Purchtable.PurchId).LineAmount;
            Less_advance_payment            = Total_Value - Final_payment;

            Manufactured_By                 = _Purchtable.BITManufacturedBy;
            Address_Import                  = _Purchtable.BITAddress;
            Port_Of_Loading                 = _Purchtable.BITPortOfLoading;
            Port_Of_Destination             = _Purchtable.BITPortOfDestination;
            Term_Of_Transportation          = _Purchtable.BITTermOfTransportation;
            Freight_and_Insurance_covered   = _Purchtable.BITFreight;
            Payment_Terms                   = _Purchtable.BITPaymentTerms;
            Quality_Certificate             = _Purchtable.BITQuality;

            element.send(_Purchtable);
        }
    }

    return ret;
}




 Basic Address Book structure in Ax2012
This is a quick overview of the main tables involved in the address book functionality of Ax2012.

In Ax2009, the integration between the address book and 'entities', like customers, suppliers, etc was a bit flaky. This has been

tightened up in Ax2012 so that now the address book has a much more important role in maintaining basic data like customer names and

addresses etc.

A few of the tables you'll need to know about are:


Table Description
DirPartyTable Global address book. This will contain entries for all people and organizations
you deal with, including customers, suppliers, employees, etc.


This information is maintained across the entire organization. NB the table structure often refers to address book entries as

'parties'. Generally other records (like customer, supplier, etc) will reference a record in this table by a field named Party.
LogisticsLocation This is a single 'location' that can be attached to one or more address book entries. This is similar in

principle to the old 'Address' table from Ax2009, that no longer exists - The main difference now being that the location header

always points to an address book entry, whereas in 2009 the Address table could point to anything.

Note that this is not an address - Physical address details are stored in
LogisticsPostalAddress
LogisticsPostalAddress A postal address, linked to a LogisticsLocation record via field Location.
LogisticsElectronicAddress 'Electronic' address details, such as email, phone, web address etc.

Each different type of address is represented as a separate record, delineated by 'Type'. This links to the location record.
DirPartyLocation This table links entries in the LogisticsLocation table to an address book entry (DirPartyTable).
LogisticsLocationRole This defines types of roles that an address are classified as, such as "Delivery", "Invoice", etc.
DirPartyLocationRole Links a location role type (LogisticsLocationRole) and an address book entry (DirPartyTable)
DirPartyPostalAddressView (view) This is a view that collates address book entries with their linked postal addresses

A few of the address book tables you should know about


The following code sample shows how we could obtain the postal addresses for a customer. NB You would preferably use a view or joined

queries to get this information. I've expanded it out to demonstrate the relationships.


static void ShowCustomerAddressBookDetails(Args _args)
{
    CustTable               custTable;
    DirPartyTable           dirPartyTable;
    DirPartyLocation        partyLocation;
    LogisticsLocation       logisticsLocation;
    LogisticsPostalAddress  postalAddress;
    ;
    custTable       = custTable::find('2014');
    dirPartyTable   = dirPartyTable::findRec(custTable.Party);
    while select partyLocation
        where   partyLocation.Party     == dirPartyTable.RecId
    {
        logisticsLocation = logisticsLocation::find(partyLocation.Location);       
        if(logisticsLocation.IsPostalAddress)
        {
            postalAddress = LogisticsPostalAddress::findByLocation(logisticsLocation.RecId);           
            info(strFmt("%1 - %2",
                logisticsLocation.Description,
                postalAddress.CountryRegionId));
        }       
    }
}

Obtaining postal addresses from a customer

And to get the email addresses:

static void ShowCustomerEmailAddresses(Args _args)
{
    CustTable                   custTable;
    DirPartyTable               dirPartyTable;
    DirPartyLocation            partyLocation;
    LogisticsLocation           logisticsLocation;
    LogisticsElectronicAddress  electronicAddress;
    ;
    custTable       = custTable::find('2014');
    dirPartyTable   = dirPartyTable::findRec(custTable.Party);
    while select partyLocation
        where   partyLocation.Party     == dirPartyTable.RecId
    {
        logisticsLocation = logisticsLocation::find(partyLocation.Location);       
        while select electronicAddress
            where   electronicAddress.Location  == logisticsLocation.RecId
            &&      electronicAddress.Type      == LogisticsElectronicAddressMethodType::Email
        {           
            info(strFmt("%1",electronicAddress.Locator));
        }       
    }
}


Obtain customer email addresses


    The following code sample retrieves the phone numbers attached to a warehouse. It was added in response to a question from adiso.


static void FindPhoneNumbersAttachedToWarehouse(Args _args)
{

    InventLocation                      inventLocation;
    LogisticsEntityPostalAddressView    postalAddressView;
    LogisticsElectronicAddress          elecAddress;
    LogisticsLocation                   contactLocation;
   
    inventLocation = inventLocation::find('11');
   
    if(inventLocation)
    {
        while select postalAddressView 
            where   postalAddressView.Entity            == inventLocation.RecId
            &&      postalAddressView.EntityType        == LogisticsLocationEntityType::Warehouse
        {               
            while select elecAddress               
                where   elecAddress.Type                == LogisticsElectronicAddressMethodType::Phone
            join contactLocation                                   
                where   contactLocation.ParentLocation  == postalAddressView.Location
                &&      contactLocation.RecId           == elecAddress.Location
            {           
                info(elecAddress.Locator); 
            }                 
        }
    }

}

           
static void GetCustCityAlfasith(Args _args)
{
    Custtable    Custtable;
    Str Description;
    Str    address;
    ;
    Custtable = Custtable::find("1101");
    info(strfmt("Location : %1",Dirparty::PrimarypostalAddress(Custtable.Party).displayLocationDescription()));
    info(strfmt("City     : %1",Dirparty::primaryPOstalAddress(Custtable.Party).City));
    info(strfmt("Country  : %1",Dirparty::primaryPOstalAddress(Custtable.Party).CountryRegionId));
}


//BP Deviation Documented
display Description description()
{
    LogisticsElectronicAddress electronicAddress;

    electronicAddress = DirParty::primaryElectronicAddress(this.Party, LogisticsElectronicAddressMethodType::Phone);

    return electronicAddress ? electronicAddress.Description : '';
}



Contoh :
select _VendTable where _VendTable.AccountNum    == _getRecordVendPurchOrderJour.OrderAccount;
Contact = DirParty::primaryElectronicAddress(_VendTable.Party, LogisticsElectronicAddressMethodType::Phone).Description;
Locator = DirParty::primaryElectronicAddress(_VendTable.Party, LogisticsElectronicAddressMethodType::Phone).Locator;

0 comments:

A financial dimension value is based on the record and has been used on a transaction. You cannot delete the record

  SOLUTION delete in table DimensionAttributeLevelValue base on Bank Account  :  and Delete the Bank Account FINISH