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' 我今 ...
随机推荐
- 【Mood-17】 github中在本地进行上传的时候出现ERROR: Repository not found. fatal: The remote end hung up unexpectedly
一开始出现这个错误的时候还感觉很奇怪,我明明在在本地中相应的库文件夹命令中输入: vim ./git/config 将文件中的 [remote “origin"]部分去掉!
- Android小项目之四 自动更新检查的逻辑
------- 源自梦想.永远是你IT事业的好友.只是勇敢地说出我学到! ---------- 按惯例,写在前面的:可能在学习Android的过程中,大家会和我一样,学习过大量的基础知识,很多的知识点 ...
- 要检测两个C文件的代码的抄袭情况
将抄袭部分输出 如果只是变量名替换了 也算抄袭 如果输入了一些干扰代码以防止被检测出来 也算抄袭专业程序代写c++程序代写
- java jdbc连接mysql
JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用Java语言编写的类和接口 ...
- 文本替换sed+字段处理cut,join+awk重新编排字段
[1]sed工具(Stream Editor)--流编辑器 sed 本身也是一个管线(管道)命令,可以分析 standard input 的啦! 而且 sed 还可以将数据进行取代.删除.新增.截取特 ...
- 谷歌浏览器-如何让Chrome默认以隐身模式启动?
桌面图标右键属性,在“目标”后添加参数“ --incognito”(注意是双短划线,不包括双引号,双短划线前加一空格)就可以直接以隐身模式启动Chrome浏览器
- SharePoint 2010 "客户端不支持使用windows资源管理器打开此列表" 解决方法
SharePoint 2010 在“库”--“库工具”,有一个“使用资源管理器打开”的按钮,点上去报“客户端不支持使用windows资源管理器打开此列表”.如图: 解决方案:在“开始”--“管理工具” ...
- nodejs4-模块和包
模块和包: 定义模块的方法跟sea.js类似,暴露一个接口也是使用exports. 调用一个接口就是使用require 注意:在引入模块的时候如果是同级目录需要加./,否则会报错 除了可以使用ex ...
- 实现百度外卖APP个人中心头像"浪"起来的动画效果
让你的头像浪起来~~~~~ DEMO 地址:网页链接,点击下载 你需要知道的 CADisplayLink 简单的说就是一定时器,其根本利用刷帧和屏幕频率一样来重绘渲染页面. 其创建方式: [Objec ...
- spring注解中使用properties文件
一.只读取单个 properties 文件 1.在 spring 的配置文件中,加入 引入命名空间: xmlns:util="http://www.springframework.org/s ...