To Find or Update the customer primary Address in Ax 2012

Source: Internet
Author: User

To Find or Update the customer primary Address in Ax, can try following code. Relation between Dirpartytable and CustTable slightly changed in Ax for you need to re-learn about this.

static void Jay_updateaddress (Args _args) {

container roles;

DirParty DirParty;

Dirpartypostaladdressview Addressview;

Logisticspostaladdress address;

CustTable CustTable;

Dirpartylocation partylocation;

;

Ttsbegin;

CustTable = Custtable::find ("Cust-000025");

Address = DirParty::p rimarypostaladdress (Custtable.party); Find primary Address

/* Locate the first address and update the first address to the primary address

Select Firstonly Address Join Forupdate partylocation

where partylocation.location = = address. Location

&& Partylocation.party = = Custtable.party;

Partylocation.isprimary = Noyes::yes;

Partylocation.update ();

*/

Address. City = "Cangzhou";

Address. State = "Hebei province";

Addressview.party = Custtable.party;

Addressview.initfrompostaladdress (address);

DirParty = Dirparty::constructfrompartyrecid (Custtable.party);

roles = [Logisticslocationrole::findbytype (logisticslocationroletype::business). RECID]; Address Type

Dirparty.createorupdatepostaladdress (Addressview,roles);

Ttscommit;

Info ("Xixi");

}

Note:createorupdatepostaladdress method is useful for both creating or updating the customer address. If you were providing the existing Dirpartyid then it would update the customer address, in case of new Dirpartyid it would c reate a new address.

To Find or Update the customer primary Address in Ax 2012

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.