首页 > 其他 > 详细

To Find or Update customer primary Address in Ax 2012

时间:2015-06-30 12:43:39      阅读:271      评论:0      收藏:0      [点我收藏+]

To Find or Update customer primary Address in Ax 2012 you can try following code. Relation between dirpartytable and custtable slightly changed in Ax 2012 so 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::primaryPostalAddress(CustTable.Party);   //找到主要地址        

/* 找到第一个地址, 并将第一个地址更新为主要地址    

select firstonly address join forupdate partyLocation                        

where partyLocation.Location == address.Location            

&& partyLocation.Party == CustTable.Party;    

partyLocation.IsPrimary = NoYes::Yes;    

partyLocation.update();    

*/        

address.City    = "沧州";    

address.State   = "河北省";    

addressView.Party = CustTable.Party;    

addressview.initFromPostalAddress(address);    

DirParty = DirParty::constructFromPartyRecId(CustTable.Party);    

roles = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Business).RecId]; // 地址类型    

DirParty.createOrUpdatePostalAddress(addressView,roles);            

ttsCommit;        

info("xixi");    

}

 

 

Note: createOrUpdatePostalAddress method is useful for both creating or updating the customer address. if you are providing the existing dirpartyid then it will update the customer address ,in case of new dirpartyid it will create a new address.

 

To Find or Update customer primary Address in Ax 2012

原文:http://www.cnblogs.com/xiangliqi/p/4609892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!