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' 我今 ...
随机推荐
- tcpdump常用命令
1. 只抓syn包 tcpdump -i eth1 'tcp[tcpflags] = tcp-syn' 2. 只抓ack包 tcpdump -nni xgbe1 dst host 191.168.10 ...
- 【¥200代金券、iPad等您来拿】 阿里云9大产品免费公测#10月9日-11月6日#
#10.09-11.06#200元代金券.iPad大奖, 9大产品评测活动! 亲爱的阿里云小伙伴们: 云产品的多样性(更多的云产品)也是让用户深度使用云计算的关键.今年阿里云产品线越来越丰富,小云搜罗 ...
- 错误"Lc.exe 已退出,代码 -1 "
今天做项目的时候突然出现编译不通过,错误为Lc.exe已退出,代码为-1.这让我郁闷了至少30分钟,后来上网查了一下,才知道原因所在,我们项目中使用了第三方组件(Infragistics)造成的,至于 ...
- 10 个顶级 JavaScript 动画框架推荐
使用JavaScript可以做出一些引人注目的动画效果,但通常不太容易实现.本文为你整理了10个非常优秀的JavaScript动画框架,使用它们你可以轻松实现动画效果.1. RaphaëlRaphaë ...
- ng-sortable-支持触屏的拖拽排序
1.首先是到https://github.com/a5hik/ng-sortable/tree/master/dist下载所需的文件:ng-sortable.min.js,ng-sortable.cs ...
- 修复浏览器不支持Array自带的indexOf方法的扩展
JavaScript中Array的indexOf方法支持的浏览器有:IE9+.Firefox 2+.Safari 3+.Opera 9.5+和Chrome 如果想要在不支持的浏览器中使用indexOf ...
- 详细js中(function(window,document,undefined))的作用
在jquery插件中我们经常看到以下这段代码 对于很多初学者来说很难明白这表示什么,下边我将为大家介绍其相应的作用. 1.代码最前面的分号,可以防止多个文件压缩合并以为其他文件最后一行语句没加分号,而 ...
- java使用POI jar包读写xls文件
主要使用poi jar来操作excel文件.代码中用到的数据库表信息见ORACLE之表.使用public ArrayList<Person> getPersonAllRecords()获得 ...
- Part 18 Indexes in sql server
Indexes in sql server Clustered and nonclustered indexes in sql server Unique and Non Unique Indexes ...
- SQL事务隔离级别
数据库是要被广大客户所共享访问的,那么在数据库操作过程中很可能出现以下几种不确定情况. 更新丢失(Lost update) 两个事务都同时更新一行数据,但是第二个事务却中途失败退出,导致对数据的两个修 ...