X++ Code for Creating New Customer and also update Address of the
customer
static void
SK_CreateCustomerandupdateCustomerAddres(Args _args)
{
CustTable
custTable;
AccountNum
accountNum = 'ABC-123';
CustGroupId
custGroupId = '10';
Name
name = 'ABC';
DirParty
dirParty;
DirPartyPostalAddressView
dirPartyPostalAddressView;
custTable =
CustTable::find(accountNum);
if(!custTable) // if customer not exits
{
ttsBegin;
custTable.clear();
custTable.initValue();
custTable.AccountNum = accountNum;
custTable.CustGroup = custGroupId;
custTable.insert(DirPartyType::Organization, name);
dirParty = DirParty::constructFromCommon(custTable);
dirPartyPostalAddressView.LocationName = 'ABC-AUTO';
dirPartyPostalAddressView.City = 'London';
dirPartyPostalAddressView.Street = 'Dover
Street';
dirPartyPostalAddressView.StreetNumber = '123';
dirPartyPostalAddressView.CountryRegionId = 'GBR';
dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
ttsCommit;
}
else // if customer exits
updates the address of the customer
{
ttsBegin;
dirParty = DirParty::constructFromCommon(custTable);
dirPartyPostalAddressView.LocationName = 'ABC-AUTO';
dirPartyPostalAddressView.City =
'Germany';
dirPartyPostalAddressView.Street = 'Germany
Street';
dirPartyPostalAddressView.StreetNumber = '123';
dirPartyPostalAddressView.CountryRegionId = 'GBR';
dirPartyPostalAddressView.IsPrimary=1;
dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
ttsCommit;
}
}
Referred link:
This comment has been removed by the author.
ReplyDelete