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' 我今 ...
随机推荐
- python 基础——generate生成器
通过列表表达式可以直接生成列表,不过列表一旦生成就需要为所有元素分配内存,有时候会很消耗资源. 所以,如果列表元素可以按照某种算法推算出来,这样就不必创建完整的list,从而节省大量的内存空间. 在P ...
- Linux的SOCKET编程详解
1. 网络中进程之间如何通信 进 程通信的概念最初来源于单机系统.由于每个进程都在自己的地址范围内运行,为保证两个相互通信的进 程之间既互不干扰又协调一致工作,操作系统为进程通信提供了相应设施,如 U ...
- poj 1695 动态规划
思路:和黑书上的跳舞机类似 #include<map> #include<set> #include<cmath> #include<queue> #i ...
- canvas基础2--绘制图形
栅格 绘制矩形 不同于SVG,HTML中的元素canvas只支持一种原生的图形绘制:矩形.所有其他的图形的绘制都至少需要生成一条路径.不过,我们拥有众多路径生成的方法让复杂图形的绘制成为了可能. 首先 ...
- macOS10.12允许所有来源设置
如何调出允许所有来源呢? 很简单一行命令搞定 调出允许所有来源 1.打开终端执行命令 sudo spctl --master-disable 2.你在打开偏好设置--> 安全与隐私 好了赶快 ...
- kettle菜鸟学习笔记3----kettle数据库连接错误及解决
数据库连接测试时,所有的参数信息都填写正确,却报错了. 或者,没有进行数据库连接测试,直接保存了当前数据库连接,然后在浏览,选择目标表时报错: 或者其他别的关于数据库连接的错误…… 第一个要考虑的就是 ...
- jQuery简介<思维导图>
jQuery是继prototype之后有一个优秀的Javascript库,它由John Resig创建于2006年1月.它简化了遍历HTML文档.操作DOM.处理事件.执行动画和Ajax的操作.它独特 ...
- windows server 2008 防火墙配置
防火墙的配置主要是过滤用户是否能够访问服务器,哪些用户能够访问,哪些用户不能访问.类似于交换机上的acl(访问控制列表) 在windows服务器上有入站规则以及出站规则,那我们首先得了解一下什么是入站 ...
- File.Create创建文件后,需要释放资源
if (!File.Exists(SavePath)) { File.Create(SavePath).Close(); }
- [转] 正则表达式 oracle
地址:http://www.cnblogs.com/Azhu/archive/2012/04/03/2431127.html 从oracle database 10gsql 开发指南中copy的. 正 ...