How to using x++ creating Vendors [AX2012]
.//Create party for the vendor
public void createParty(VendorRequestCreate _vendorRequestCreate)
{
;
if(_vendorRequestCreate.DirPartyType == DirPartyBaseType::Person)
{
dirPerson.Name = _vendorRequestCreate.VendorName;
dirPerson.NameAlias = _vendorRequestCreate.FirstName;
dirPerson.NameSequence = dirNameSequence::find('First Last').RecId;
dirPerson.insert(); dirPersonName.FirstName = _vendorRequestCreate.FirstName;
dirPersonName.MiddleName = _vendorRequestCreate.MiddleName;
dirPersonName.LastName = _vendorRequestCreate.LastName;
dirPersonName.ValidFrom = DateTimeUtil::newDateTime(systemDateGet(),str2time ('00:00:00'),DateTimeUtil::getUserPreferredTimeZone());
dirPersonName.ValidTo = DateTimeUtil::maxValue();
dirPersonName.Person = dirPerson.RecId;
dirPersonName.insert(); dirParty = new DirParty(dirPerson);
}
else
{
dirOrganisation.Name = _vendorRequestCreate.VendorName;
dirOrganisation.NameAlias = _vendorRequestCreate.FirstName;
dirOrganisation.LanguageId = 'EN-US';
dirOrganisation.KnownAs = _vendorRequestCreate.VendorName;
dirOrganisation.PhoneticName = _vendorRequestCreate.VendorName;
dirOrganisation.insert(); dirParty = new DirParty(dirOrganisation);
} } .//Create vendor and associate with vendor
public void convertToVendor(VendorRequestCreate _vendorRequestCreate)
{
VendorRequestCreate vendorRequestCreate = VendorRequestCreate::find(_vendorRequestCreate.VendorNo,true);
; if(_vendorRequestCreate.DirPartyType == DirPartyBaseType::Person)
vendTable.Party = dirPerson.RecId;
else
vendTable.Party = dirOrganisation.RecId; ttsBegin;
vendTable.AccountNum = NumberSeq::newGetNum(VendParameters::numRefVendAccount()).num();
ttsCommit;
if(vendTable.AccountNum == '')
vendTable.AccountNum= int2str(_vendorRequestCreate.VendorNo); vendTable.Currency = _vendorRequestCreate.CurrencyCode;
vendTable.VendGroup = _vendorRequestCreate.VendGroupId;
vendTable.PaymTermId = _vendorRequestCreate.PaymTermId;
vendTable.DefaultDimension = _vendorRequestCreate.DefaultDimension;
vendTable.OneTimeVendor = _vendorRequestCreate.OneTimeSupplier;
vendTable.PaymMode = _vendorRequestCreate.PaymMode;
vendTable.BankAccount = _vendorRequestCreate.BankAccount;
vendTable.WI_Remarks = _vendorRequestCreate.Remarks;
vendTable.WI_DepartmentEmail = _vendorRequestCreate.DepartmentEmail;
vendTable.insert(); this.createPostalAddress(_vendorRequestCreate);
this.createCommAddress(_vendorRequestCreate);
this.createBankDetails(_vendorRequestCreate,vendTable.AccountNum);
this.createContact(_vendorRequestCreate,vendTable.Party); if(vendTable.RecId)
{
vendorRequestCreate.VendAccount = vendTable.AccountNum;
vendorRequestCreate.update();
info(strFmt('Vendor %1 has been successfully created',vendTable.AccountNum));
} } .//Create postal address
public void createPostalAddress(VendorRequestCreate _vendorRequestCreate)
{
VendorRequestAddress vendorRequestAddress;
DirPartyPostalAddressView dirPartyPostalAddressView;
; select Addressing, LogisticsAddressCity, LogisticsAddressCountryRegionId, LogisticsAddressStateId,
LogisticsAddressZipCodeId from vendorRequestAddress
where vendorRequestAddress.WI_VendorRequestCreate == _vendorRequestCreate.RecId; // Create postal address
if(dirPerson.RecId || dirOrganisation.RecId)
{
dirPartyPostalAddressView.LocationName = 'Primary business';
dirPartyPostalAddressView.Address = vendorRequestAddress.Addressing;
dirPartyPostalAddressView.City = vendorRequestAddress.LogisticsAddressCity;
dirPartyPostalAddressView.ZipCode = vendorRequestAddress.LogisticsAddressZipCodeId;
dirPartyPostalAddressView.State = vendorRequestAddress.LogisticsAddressStateId;
dirPartyPostalAddressView.Street = vendorRequestAddress.Addressing;
//dirPartyPostalAddressView.Street = 'Dover Street';
//dirPartyPostalAddressView.StreetNumber = '123';
dirPartyPostalAddressView.CountryRegionId = vendorRequestAddress.LogisticsAddressCountryRegionId; dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
} } .//Create communication details
public void createCommAddress(VendorRequestCreate _vendorRequestCreate)
{ VendorRequestCommunication vendorRequestCommunication;
; select Phone1, Phone2, Email, Fax from vendorRequestCommunication
where vendorRequestCommunication.WI_VendorRequestCreate == _vendorRequestCreate.RecId; //Phone 1
if(vendorRequestCommunication.Phone1 != '' && vendTable.Party != )
{
logisticsLocation.clear();
logisticsLocation = LogisticsLocation::create('Phone', NoYes::No); dirPartyContactInfoView.LocationName = 'Primay Phone 1';
dirPartyContactInfoView.Locator = vendorRequestCommunication.Phone1;
dirPartyContactInfoView.Type = LogisticsElectronicAddressMethodType::Phone;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
} //Phone 2
if(vendorRequestCommunication.Phone2 != '' && vendTable.Party != )
{
logisticsLocation.clear();
logisticsLocation = LogisticsLocation::create('Phone', NoYes::No); dirPartyContactInfoView.LocationName = 'Primay Phone 2';
dirPartyContactInfoView.Locator = vendorRequestCommunication.Phone2;
dirPartyContactInfoView.Type = LogisticsElectronicAddressMethodType::Phone;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::No;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
if(vendorRequestCommunication.Email != '' && vendTable.Party != )
{
logisticsLocation.clear();
logisticsLocation = LogisticsLocation::create('Phone', NoYes::No); dirPartyContactInfoView.LocationName = 'Primay Email';
dirPartyContactInfoView.Locator = vendorRequestCommunication.Email;
dirPartyContactInfoView.Type = LogisticsElectronicAddressMethodType::Email;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
} //Fax
if(vendorRequestCommunication.Fax != '' && vendTable.Party != )
{
logisticsLocation.clear();
logisticsLocation = LogisticsLocation::create('Phone', NoYes::No); dirPartyContactInfoView.LocationName = 'Primay Fax';
dirPartyContactInfoView.Locator = vendorRequestCommunication.Fax;
dirPartyContactInfoView.Type = LogisticsElectronicAddressMethodType::Fax;
dirPartyContactInfoView.Party = vendTable.Party;
dirPartyContactInfoView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(dirPartyContactInfoView);
}
} .//Create bank details for the vendor
private void createBankDetails(WI_VendorRequestCreate _vendorRequestCreate,
VendAccount _vendAcc)
{
VendBankAccount vendBankAccount;
LogisticsLocation lLogisticsLocation;
LogisticsPostalAddress logisticsPostalAddress; ; ttsBegin; lLogisticsLocation.Description = _vendorRequestCreate.FirstName;
lLogisticsLocation.insert(); logisticsPostalAddress.Street = _vendorRequestCreate.VendBankAddress;
logisticsPostalAddress.Address = _vendorRequestCreate.VendBankAddress;
logisticsPostalAddress.Location = lLogisticsLocation.RecId;
logisticsPostalAddress.insert(); vendBankAccount.AccountID = subStr(_vendorRequestCreate.BankAccount,,);
vendBankAccount.Name = _vendorRequestCreate.BankAccount;
vendBankAccount.AccountNum = _vendorRequestCreate.BankAccountNum;
vendBankAccount.VendAccount = _vendAcc;
vendBankAccount.CurrencyCode = _vendorRequestCreate.CurrencyCode;
vendBankAccount.BankGroupID = BankAccountTable::find(vendBankAccount.AccountID).BankGroupId;
vendBankAccount.Location = lLogisticsLocation.RecId;
vendBankAccount.WI_BeneficiaryName = _vendorRequestCreate.BeneficiaryName;
vendBankAccount.initFromBankGroup(BankGroup::find(vendBankAccount.BankGroupID)); vendBankAccount.insert();
ttsCommit;
} .
//Create contact for the vendor
private void createContact(VendorRequestCreate _vendorRequestCreate,
RefRecId _partyId)
{
ContactPerson contactPerson;
DirPersonName lDirPersonName;
DirPerson lDirPerson;
DirParty lDirParty;
LogisticsLocation lLogisticsLocation;
DirPartyContactInfoView lDirPartyContactInfoView;
; //Create party for Contact
lDirPerson.Name = _vendorRequestCreate.ContactPersonName;
lDirPerson.NameAlias = _vendorRequestCreate.ContactPersonName;
lDirPerson.NameSequence = dirNameSequence::find('First Last').RecId;
lDirPerson.insert(); lDirPersonName.FirstName = _vendorRequestCreate.ContactPersonName;
//lDirPersonName.MiddleName = _vendorRequestCreate.ContactPersonName;
//lDirPersonName.LastName = _vendorRequestCreate.LastName;
lDirPersonName.ValidFrom = DateTimeUtil::newDateTime(systemDateGet(),str2time ('00:00:00'),DateTimeUtil::getUserPreferredTimeZone());
lDirPersonName.ValidTo = DateTimeUtil::maxValue();
lDirPersonName.Person = lDirPerson.RecId;
lDirPersonName.insert(); lDirParty = new DirParty(lDirPerson); //Create contact and associate with party
contactPerson.ContactForParty = vendTable.Party;
contactPerson.Party = lDirPerson.RecId;
contactPerson.insert(); //Create contact number
if(_vendorRequestCreate.ContactPersonNo != '')
{
lLogisticsLocation.clear();
lLogisticsLocation = LogisticsLocation::create('Phone', NoYes::No); lDirPartyContactInfoView.LocationName = 'Primay Phone';
lDirPartyContactInfoView.Locator = _vendorRequestCreate.ContactPersonNo;
lDirPartyContactInfoView.Type = LogisticsElectronicAddressMethodType::Phone;
lDirPartyContactInfoView.Party = contactPerson.Party;
lDirPartyContactInfoView.IsPrimary = NoYes::Yes;
lDirParty.createOrUpdateContactInfo(lDirPartyContactInfoView);
}
}
How to using x++ creating Vendors [AX2012]的更多相关文章
- 【解决方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed;
一个错误会浪费好多青春绳命 鉴于此,为了不让大家也走弯路,分享解决方案. [错误代码提示] StandardWrapper.Throwableorg.springframework.beans.fac ...
- 如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites]
如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites] 一.布局页面介绍[Abo ...
- 启用SQLite的Data Provider 运行WECOMPANYSITE时遇到ERROR CREATING CONTEXT 'SPRING.ROOT': ERROR THROWN BY A DEPENDENCY OF OBJECT 'SYSTEM.DATA.SQLITE'
从网上下载的源码WeCompanySite,运行时报错 Error creating context 'spring.root': Error thrown by a dependency of ob ...
- Creating a Clean, Minimal-Footprint ASP.NET WebAPI Project with VS 2012 and ASP.NET MVC 4
Creating a Clean, Minimal-Footprint ASP.NET WebAPI Project with VS 2012 and ASP.NET MVC 4 Building O ...
- Creating a SharePoint Sequential Workflow
https://msdn.microsoft.com/en-us/library/office/hh824675(v=office.14).aspx Creating a SharePoint Seq ...
- [bigdata] 启动CM出现 “JDBC Driver class not found: com.mysql.jdbc.Driver” 以及“Error creating bean with name 'serverLogFetcherImpl'”问题的解决方法
问题:“JDBC Driver class not found: com.mysql.jdbc.Driver” 通过以下命令启动cm [root@hadoop1 ~]# /etc/init.d/cl ...
- 【安卓】aidl.exe E 10744 10584 io_delegate.cpp:102] Error while creating directories: Invalid argument
这几天在使用.aidl文件的时候eclipse的控制台总是爆出如下提示: aidl.exe E 10744 10584 io_delegate.cpp:102] Error while creatin ...
- Failed creating java D:/jre6/bin/client/jvm.dll
Failed creating java D:/jre6/bin/client/jvm.dll 标记一下 坑爹啊! 我特么装了一个64位的eclipse 结果报错 目录下确实有这个文件. 我想说 6 ...
- Spring 异常:Error creating bean with name
异常信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx' 我今 ...
随机推荐
- Ultra Edit常用正则表达式
一.怎样可以删除包含特殊字符的行? 你可以用正则表示式全部替换命令替换行中包含的字符.要执行这个操作,你应该先进行查找: 查找: %*YOUR STRING*^p 替换为: (随便什么文字) 帮助文件 ...
- UICollectionView 简单应用和实际操作
1.网格视图 UICollectionView 网格布局 UICollectionViewFlowLayout系统图自带网格布局 系统自带的网格布局 UICollectionViewFl ...
- 1. RAID在数据库存储上的应用
随着单块磁盘在数据安全.性能.容量上呈现出的局限,磁盘阵列(Redundant Arrays of Inexpensive/Independent Disks,RAID)出现了,RAID把多块独立的磁 ...
- 无线网络(WLAN)常见加密方式介绍
在使用无线路由器配置wifi安全设定的时候经常会遇到各种加密方式,即不懂意思也不知道如何选择.本文将对此做一个简单的介绍. 1.WEP 有线等效协议(Wired Equivalent Privacy, ...
- 【转】驱动中的类class和节点
原文出处:http://blog.chinaunix.net/uid-23036581-id-2230558.html 一个类是一个设备的高级视图, 它抽象出低级的实现细节. 驱动可以见到一个SCSI ...
- Kinect For Windows V2开发日志九:侦测并绘制人体骨架
简介 在上一篇<侦测.追踪人体骨架>里,介绍了关节点的使用办法,这一篇记录将关节点与OpenCV结合的绘图方法. 代码 #include <iostream> #include ...
- 转: https 单向双向认证说明_数字证书, 数字签名, SSL(TLS) , SASL
转自: http://www.cnblogs.com/mailingfeng/archive/2012/07/18/2597392.html 因为项目中要用到TLS + SASL 来做安全认证层. 所 ...
- img 元素无法获取高度的问题
项目里有这么一个功能,需要 ajax 从服务器端获取数据,然后本地生成 DOM 结构再 append 到页面上. 其中的图片是直接拿到的图像数据,而不是 url,所以据此生成 dataURI 赋值给 ...
- 创建App IDs时选择App ID Prefix才能勾选push notifications
- JAXL发送房间消息
使用composer形式安装的JAXL <?php require_once "vendor/autoload.php"; $client = new JAXL(array( ...