static void AXAPTAEXP_ExportCustomerAddress(Args _args)
{
#file
CustTable custTable;
DirPartyTable dirPartyTable;
DirPartyLocation dirPartyLocation;
LogisticsLocation logisticsLocation;
LogisticsPostalAddress logisticsPostalAddress;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
SysExcelFont font;
int row;
LogisticsPostalAddressView view;
fileName fileName = "D:\\ address Export\\CustAddress.xlsx";
FileIoPermission filepermission;
// intializing classes to export excel
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
if (WINAPI::fileExists(fileName))
{
WINAPI::deleteFile(fileName);
}
// Setting Header values
cell = cells.item(1, 1);
cell.value("AccountNum ");
font = cell.font();
font.bold(true);
cell = cells.item(1, 2);
cell.value("LocationID");
font = cell.font();
font.bold(true);
cell = cells.item(1, 3);
cell.value("Name ");
font = cell.font();
font.bold(true);
cell = cells.item(1, 4);
cell.value("Address");
font = cell.font();
font.bold(true);
cell = cells.item(1, 5);
cell.value("State ");
font = cell.font();
font.bold(true);
cell = cells.item(1, 6);
cell.value("City");
font = cell.font();
font.bold(true);
cell = cells.item(1, 7);
cell.value("CountryRegionId ");
font = cell.font();
font.bold(true);
cell = cells.item(1, 8);
cell.value("Street");
font = cell.font();
font.bold(true);
cell = cells.item(1, 9);
cell.value("County ");
font = cell.font();
font.bold(true);
cell = cells.item(1, 10);
cell.value("ZipCode");
font = cell.font();
font.bold(true);
row = 1;
// inserting data row wise
while select AccountNum, Party from custTable
join RecId from dirPartyTable
where dirPartyTable.RecId == custTable.Party
join Location, Party from dirPartyLocation
where dirPartyLocation.Party == custTable.Party
join RecId, Description, LocationID from logisticsLocation
where logisticsLocation.RecId == dirPartyLocation.Location
join logisticsPostalAddress
where logisticsPostalAddress.Location == logisticsLocation.RecId
{
LogisticsPostalAddress = LogisticsPostalAddress::findByLocation(LogisticsLocation::findByLocationId(logisticsLocation.LocationID).RecId);
row++;
cell = cells.item(row, 1);
cell.value(any2str(custTable.AccountNum));
cell = cells.item(row, 2);
cell.value(any2str(logisticsLocation.LocationId));
cell = cells.item(row, 3);
cell.value(any2str(logisticsLocation.Description));
cell = cells.item(row, 4);
cell.value(any2str(LogisticsPostalAddress.Address));
cell = cells.item(row, 5);
cell.value(any2str(LogisticsPostalAddress.State));
cell = cells.item(row, 6);
cell.value(any2str(LogisticsPostalAddress.City));
cell = cells.item(row, 7);
cell.value(any2str(LogisticsPostalAddress.CountryRegionId));
cell = cells.item(row, 8);
cell.value(any2str(LogisticsPostalAddress.Street));
cell = cells.item(row, 9);
cell.value(any2str(LogisticsPostalAddress.County));
cell = cells.item(row, 10);
cell.value(any2str(LogisticsPostalAddress.ZipCode));
}
application.displayAlerts(false);
worksheet.columns().autoFit();
workbook.saveAs(fileName);
workbook.comObject().save();
workbook.saved(true);
application.quit();
info(strFmt("File saved in %1", fileName));
}
Showing posts with label customer addresses. Show all posts
Showing posts with label customer addresses. Show all posts
13 Nov 2018
18 Oct 2018
Update Customer/Vendor address through code in AX 2012
static void updatecustomeraddress(Args _args)
{
CustTable custTable;
DirPartyTable dirPartyTable;
DirPartyLocation dirPartyLocation;
DirPartyLocationRole dirPartyLocationRole;
LogisticsLocation logisticsLocation;
LogisticsLocationRole logisticsLocationRole;
LogisticsPostalAddress logisticsPostalAddress;
while select * from custTable where custTable.AccountNum == "BRIG" // if you want vendor change here
join dirPartyTable
where dirPartyTable.RecId == custTable.Party
join dirPartyLocation
where dirPartyLocation.Party == custTable.Party
// if you want role specific un-commented below code
/*join dirPartyLocationRole
//where dirPartyLocationRole.PartyLocation == dirPartyLocation.RecId
//join logisticsLocationRole
//where logisticsLocationRole.RecId == dirPartyLocationRole.LocationRole
// && logisticsLocationRole.Type == LogisticsLocationRoleType::Delivery*/
join logisticsLocation
where logisticsLocation.RecId == dirPartyLocation.Location
join logisticsPostalAddress
where logisticsPostalAddress.Location == logisticsLocation.RecId
{
ttsbegin;
logisticsPostalAddress.selectForUpdate(true);
logisticsPostalAddress.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
logisticsPostalAddress.Address = "Test address";
logisticsPostalAddress.update();
ttsCommit;
}
}
{
CustTable custTable;
DirPartyTable dirPartyTable;
DirPartyLocation dirPartyLocation;
DirPartyLocationRole dirPartyLocationRole;
LogisticsLocation logisticsLocation;
LogisticsLocationRole logisticsLocationRole;
LogisticsPostalAddress logisticsPostalAddress;
while select * from custTable where custTable.AccountNum == "BRIG" // if you want vendor change here
join dirPartyTable
where dirPartyTable.RecId == custTable.Party
join dirPartyLocation
where dirPartyLocation.Party == custTable.Party
// if you want role specific un-commented below code
/*join dirPartyLocationRole
//where dirPartyLocationRole.PartyLocation == dirPartyLocation.RecId
//join logisticsLocationRole
//where logisticsLocationRole.RecId == dirPartyLocationRole.LocationRole
// && logisticsLocationRole.Type == LogisticsLocationRoleType::Delivery*/
join logisticsLocation
where logisticsLocation.RecId == dirPartyLocation.Location
join logisticsPostalAddress
where logisticsPostalAddress.Location == logisticsLocation.RecId
{
ttsbegin;
logisticsPostalAddress.selectForUpdate(true);
logisticsPostalAddress.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
logisticsPostalAddress.Address = "Test address";
logisticsPostalAddress.update();
ttsCommit;
}
}
Get Customer/Vendor address through code in AX 2012
static void getCustomerAddress(Args _args)
{
CustTable custTable;
VendTable vendTable;
DirPartyTable dirPartyTable;
DirPartyLocation dirPartyLocation;
DirPartyLocationRole dirPartyLocationRole;
LogisticsLocation logisticsLocation;
LogisticsLocationRole logisticsLocationRole;
LogisticsPostalAddress logisticsPostalAddress;
while select * from custTable where custTable.AccountNum == "BRIG" // if you want vendor specify vendor here
join dirPartyTable
where dirPartyTable.RecId == custTable.Party
join dirPartyLocation
where dirPartyLocation.Party == custTable.Party
//If you need fetch based on role use below commented code
/*join dirPartyLocationRole
//where dirPartyLocationRole.PartyLocation == dirPartyLocation.RecId
//join logisticsLocationRole
//where logisticsLocationRole.RecId == dirPartyLocationRole.LocationRole
// && logisticsLocationRole.Type == LogisticsLocationRoleType::Delivery*/
join logisticsLocation
where logisticsLocation.RecId == dirPartyLocation.Location
join logisticsPostalAddress
where logisticsPostalAddress.Location == logisticsLocation.RecId
{
info(strFmt("%1", logisticsPostalAddress.Address));
}
}
{
CustTable custTable;
VendTable vendTable;
DirPartyTable dirPartyTable;
DirPartyLocation dirPartyLocation;
DirPartyLocationRole dirPartyLocationRole;
LogisticsLocation logisticsLocation;
LogisticsLocationRole logisticsLocationRole;
LogisticsPostalAddress logisticsPostalAddress;
while select * from custTable where custTable.AccountNum == "BRIG" // if you want vendor specify vendor here
join dirPartyTable
where dirPartyTable.RecId == custTable.Party
join dirPartyLocation
where dirPartyLocation.Party == custTable.Party
//If you need fetch based on role use below commented code
/*join dirPartyLocationRole
//where dirPartyLocationRole.PartyLocation == dirPartyLocation.RecId
//join logisticsLocationRole
//where logisticsLocationRole.RecId == dirPartyLocationRole.LocationRole
// && logisticsLocationRole.Type == LogisticsLocationRoleType::Delivery*/
join logisticsLocation
where logisticsLocation.RecId == dirPartyLocation.Location
join logisticsPostalAddress
where logisticsPostalAddress.Location == logisticsLocation.RecId
{
info(strFmt("%1", logisticsPostalAddress.Address));
}
}
Subscribe to:
Posts (Atom)
Create number sequence in D365 FO
Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...
-
how you can disable a form element, based on the value of another form element. As example, the CustTable form will be used. The examp...
-
Dialogbutton dialogButtonConfirm; ; dialogButtonConfirm = Box::yesNo("continue ", dialogButton::Yes, ...
-
AXAPTA History Axapta 1.0 Development of Axapta began in 1983 at Danish company Damgaard Data A/S. The first version of Axapta (pr...