In AX 2012 there is method formatAddress in LogisticsPostalAddress table. This method will merge all the details of the address. In my case I was updating the vendor address so I created a job as shown below:
//Something like this:
logisticsPostalAddress.Address = logisticsPostalAddress::formatAddress(logisticsPostalAddress.Street,
logisticsPostalAddress.ZipCode,
'',
logisticsPostalAddress.CountryRegionId,
'',
'');
logisticsPostalAddress.update();
Thursday, 24 May 2012
How to reduce/flush the TempDB size in AX2012
In AX 2012 all the temp data is stored in TempDB database, which normally occupies alot of space after certain days. Below is the path for TempDB:
<YourDrive>:\SQL\MSSQL10_50.MSSQLSERVER\MSSQL\TempDB
You might see on the above path that there is a a database which is of a big size in GB's. You simply need to restart SQL Server service or restart the machine. This will flush all the temp memory from this database.
Hope this helps!
<YourDrive>:\SQL\MSSQL10_50.MSSQLSERVER\MSSQL\TempDB
You might see on the above path that there is a a database which is of a big size in GB's. You simply need to restart SQL Server service or restart the machine. This will flush all the temp memory from this database.
Hope this helps!
Invalid file name message.
This is the error message you normally get when you use the the wrong file convention, As in the example below I used "\" instead of "\\" in the file path, as AX only excepts "\\":
static void ReadingFile(Args _args)
{
TextIo inputFile;
//This syntax is for reading file in a local machine, we always use "\\" instead of "\"
// AX does not read "\"
inputFile = new TextIo("C:\test.txt", 'R');
if (inputFile)
{
info("File found");
}
}
Solution:
static void ReadingFile(Args _args)
{
TextIo inputFile;
//This syntax is for reading file in a local machine, we always use "\\" instead of "\"
// AX does not read "\"
inputFile = new TextIo("C:\\test.txt", 'R');
if (inputFile)
{
info("File found");
}
}
This is the correct way. Same goes for network path, you need to use "\\\\" instead of "\\", as shown below:
static void ReadingNetworkFile(Args _args)
{
TextIo inputFile;
//This syntax is for reading file in a local machine, we always use "\\" instead of "\"
// AX does not read "\"
inputFile = new TextIo("\\\\AXServer\\test.txt", 'R');
if (inputFile)
{
info("File found");
}
}
static void ReadingFile(Args _args)
{
TextIo inputFile;
//This syntax is for reading file in a local machine, we always use "\\" instead of "\"
// AX does not read "\"
inputFile = new TextIo("C:\test.txt", 'R');
if (inputFile)
{
info("File found");
}
}
Solution:
static void ReadingFile(Args _args)
{
TextIo inputFile;
//This syntax is for reading file in a local machine, we always use "\\" instead of "\"
// AX does not read "\"
inputFile = new TextIo("C:\\test.txt", 'R');
if (inputFile)
{
info("File found");
}
}
This is the correct way. Same goes for network path, you need to use "\\\\" instead of "\\", as shown below:
static void ReadingNetworkFile(Args _args)
{
TextIo inputFile;
//This syntax is for reading file in a local machine, we always use "\\" instead of "\"
// AX does not read "\"
inputFile = new TextIo("\\\\AXServer\\test.txt", 'R');
if (inputFile)
{
info("File found");
}
}
Stack trace: Invalid attempt to call WinAPI::findFirstFile running in CIL on the client.
Stack trace: Invalid attempt to call WinAPI::findFirstFile running in CIL on the client
This error you will normally encounter when running a batch job. The issue is that batch processing doesn't suppport WINAPI::findFirstFile method. Actually I was trying to find a file in the folder and moving to some other folder, you can use this alternative:
public void run()
{
System.IO.DirectoryInfo di;
System.Type arrayType;
System.Array array;
System.IO.FileInfo fi;
FilePath filePath, moveFilePath, shortFile;
int i;
int l;
;
super();
baseFolder = tEC_InterfaceSetup.TEC_DefaultFolder +"\\";
di = new System.IO.DirectoryInfo(baseFolder);
arrayType = System.Type::GetType("System.IO.FileInfo");
array = System.Array::CreateInstance(arrayType, 1);
array = di.GetFiles("*" + #txt);
l = array.get_Length();
if (l > 0)
{
//Find the files in the base folder and iterate.
for (i = 0; i < l; i++)
{
fi = array.GetValue(i);
mainFolder = fi.get_FullName();
foundBaseFileName = fi.get_Name();
//**********Your logic************
}
InterfaceTransfer::moveFile(foundBaseFileName , moveFilePath);
}
}
server static void moveFile(str fileName, str newFileName)
{
#File
Set permissionSet;
permissionSet = new Set(Types::Class);
permissionSet.add(new FileIOPermission(fileName,#io_write));
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
CodeAccessPermission::assertMultiple(permissionSet);
System.IO.File::Move(fileName, newFileName);
CodeAccessPermission::revertAssert();
}
Hope this helps.
This error you will normally encounter when running a batch job. The issue is that batch processing doesn't suppport WINAPI::findFirstFile method. Actually I was trying to find a file in the folder and moving to some other folder, you can use this alternative:
public void run()
{
System.IO.DirectoryInfo di;
System.Type arrayType;
System.Array array;
System.IO.FileInfo fi;
FilePath filePath, moveFilePath, shortFile;
int i;
int l;
;
super();
baseFolder = tEC_InterfaceSetup.TEC_DefaultFolder +"\\";
di = new System.IO.DirectoryInfo(baseFolder);
arrayType = System.Type::GetType("System.IO.FileInfo");
array = System.Array::CreateInstance(arrayType, 1);
array = di.GetFiles("*" + #txt);
l = array.get_Length();
if (l > 0)
{
//Find the files in the base folder and iterate.
for (i = 0; i < l; i++)
{
fi = array.GetValue(i);
mainFolder = fi.get_FullName();
foundBaseFileName = fi.get_Name();
//**********Your logic************
}
InterfaceTransfer::moveFile(foundBaseFileName , moveFilePath);
}
}
server static void moveFile(str fileName, str newFileName)
{
#File
Set permissionSet;
permissionSet = new Set(Types::Class);
permissionSet.add(new FileIOPermission(fileName,#io_write));
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
CodeAccessPermission::assertMultiple(permissionSet);
System.IO.File::Move(fileName, newFileName);
CodeAccessPermission::revertAssert();
}
Hope this helps.
System.IO.IOException: The process cannot access the file because it is being used by another process.
If you encounter this error that mean that you are trying to access a file which is not closed at the moment. The file your trying to access is still open, below is the screen-shot:
Solution:
The solution is that you simple need to close the file the TextIO class. For closing the file you neeed to use this syntax:
TextIo inputFile;
;
inputFile.finalize();
// This will close the file and then you can proceed with your remianing operation on the file.
Solution:
The solution is that you simple need to close the file the TextIO class. For closing the file you neeed to use this syntax:
TextIo inputFile;
;
inputFile.finalize();
// This will close the file and then you can proceed with your remianing operation on the file.
Access denied to Bank account number(AccountNum) in table Print checks (TmpChequePrinout)
If you encounter an error "Access denied to Bank account number(AccountNum) in table Print checks (TmpChequePrinout)" when generating computerized cheque as shown below:
Solution:
Assign the AP Payment Clerk role to that user who is trying to generate the CPU cheque, this will resolve your problem.
Solution:
Assign the AP Payment Clerk role to that user who is trying to generate the CPU cheque, this will resolve your problem.
Wednesday, 23 May 2012
How to set minimum/empty, maximum date for date control in AX.
This job will explain how to set different operations on date conrol in AX using Global class:
static void GlobalClass(Args _args)
{
Date newDate;
;
//Normal Dates
info("Normal Dates:");
//Get's today's date.
info(strfmt('%1', today()));
//Get's minimum/empty date (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', Global::dateNull()));
//Get's maximum date (i.e. 12/31/2154).
info(strfmt('%1', Global::dateMax()));
//How to add 2 months in date
newDate = Global::dateMthFwd(today(), 2);
info(strfmt('%1', newDate));
}
Output:
static void GlobalClass(Args _args)
{
Date newDate;
;
//Normal Dates
info("Normal Dates:");
//Get's today's date.
info(strfmt('%1', today()));
//Get's minimum/empty date (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', Global::dateNull()));
//Get's maximum date (i.e. 12/31/2154).
info(strfmt('%1', Global::dateMax()));
//How to add 2 months in date
newDate = Global::dateMthFwd(today(), 2);
info(strfmt('%1', newDate));
}
Output:
How to get minimum/empty,maximum date and DateTime in user preferred time zone for utcDateTime control
This job will explain the simple usage of DateTimeUtill class in AX.
static void UtcDateTimeClass(Args _args)
{
Date todaysDate;
;
//UTC Date Time
info("UTC Dates:");
//Get's today's utc date time.
info(strfmt('%1', DateTimeUtil::utcNow()));
//Get's minimum utc date time (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', DateTimeUtil::minValue()));
//Get's minimum utc date time (i.e. 1/1/1900).
info(strfmt('%1', utcDateTimeNull()));
//Get's maximum utc date time (i.e. 12/31/2154).
info(strfmt('%1', DateTimeUtil::maxValue()));
//Convert UtcDateTime to normal date
todaysDate = DateTimeUtil::date(DateTimeUtil::utcNow());
info(strfmt('%1',todaysDate));
//How to get the time in user time zone
info(strfmt('%1', DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(),
DateTimeUtil::getUserPreferredTimeZone())));
}
Output:
static void UtcDateTimeClass(Args _args)
{
Date todaysDate;
;
//UTC Date Time
info("UTC Dates:");
//Get's today's utc date time.
info(strfmt('%1', DateTimeUtil::utcNow()));
//Get's minimum utc date time (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', DateTimeUtil::minValue()));
//Get's minimum utc date time (i.e. 1/1/1900).
info(strfmt('%1', utcDateTimeNull()));
//Get's maximum utc date time (i.e. 12/31/2154).
info(strfmt('%1', DateTimeUtil::maxValue()));
//Convert UtcDateTime to normal date
todaysDate = DateTimeUtil::date(DateTimeUtil::utcNow());
info(strfmt('%1',todaysDate));
//How to get the time in user time zone
info(strfmt('%1', DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(),
DateTimeUtil::getUserPreferredTimeZone())));
}
Output:
'Like' and 'Not Like' in Dynamics AX query
In X++ you can use 'Like' to get the query result: E.g
static void Job12(Args _args)
{
CustTable custTable;
;
while select custTable
where custTable.AccountNum like "11*"
{
info(strfmt('%1', custTable.AccountNum));
}
}
This job will return all the customer account starting from "11", as shown below:
In X++ you can use 'Not Like' to get the query result: E.g
static void Job13(Args _args)
{
CustTable custTable;
;
while select custTable
where !(custTable.AccountNum like "11*")
{
info(strfmt('%1', custTable.AccountNum));
}
}
This job will return all the customer account NOT starting from "11", as shown below:
static void Job12(Args _args)
{
CustTable custTable;
;
while select custTable
where custTable.AccountNum like "11*"
{
info(strfmt('%1', custTable.AccountNum));
}
}
This job will return all the customer account starting from "11", as shown below:
In X++ you can use 'Not Like' to get the query result: E.g
static void Job13(Args _args)
{
CustTable custTable;
;
while select custTable
where !(custTable.AccountNum like "11*")
{
info(strfmt('%1', custTable.AccountNum));
}
}
This job will return all the customer account NOT starting from "11", as shown below:
Reports showing username and password when opening SSRS report
When opening a report you see the username and password dialog
Now what is the possible reason for this issue. You might have changed your AX reporting service account to any other account in the reporting service extension recently, as shown below.
Solution:
The solution for this might take some more time as expected. You need to open internet explorer and Run as Administrator. The type the reporting server link as shown below:
Now you need to test one report e.g (TaxTable). Click on the Arrow sign and select 'Manage'
Now browse to the 'Datasource' node of the reprot and check what is the data source applied, your datasource will have this option selected "Credential supplied by the user running the report" as shown below:
Now by default this should be 'Windows integerated secutiy'. In order to achive this you need to delete all the reports first from the reporting server and then re-deploy all the reports from AX. Once you re-deploy the report from AX you will see all the report changed back to 'Windows integerated secutiy' option and then report will work fine. After re-deploy you window will look like this:
Now try running the report again. Report will work fine.
Now what is the possible reason for this issue. You might have changed your AX reporting service account to any other account in the reporting service extension recently, as shown below.
Solution:
The solution for this might take some more time as expected. You need to open internet explorer and Run as Administrator. The type the reporting server link as shown below:
Now you need to test one report e.g (TaxTable). Click on the Arrow sign and select 'Manage'
Now browse to the 'Datasource' node of the reprot and check what is the data source applied, your datasource will have this option selected "Credential supplied by the user running the report" as shown below:
Now by default this should be 'Windows integerated secutiy'. In order to achive this you need to delete all the reports first from the reporting server and then re-deploy all the reports from AX. Once you re-deploy the report from AX you will see all the report changed back to 'Windows integerated secutiy' option and then report will work fine. After re-deploy you window will look like this:
Now try running the report again. Report will work fine.
Report labels does not show up in X++ report
The report labels do not display, or the report shows label IDs, like Labels!@SYS2123 instead of the label values.
There are two reason for this type of issue:
1. Either you have recently moved your AX service account from AX domain admin group
2. Or your have changed your SSRS service account password
Solution:
There are two reason for this type of issue:
1. Either you have recently moved your AX service account from AX domain admin group
2. Or your have changed your SSRS service account password
Solution:
- From the Start menu, point to All Programs, click the SQL Server folder, click the Configuration Tools folder, and then click Reporting Services Configuration Manager.
- In Reporting Services Configuration Manager click Connect and then click Service Account.
- Set the password and then click Apply. The account and password should be the same as the Microsoft Dynamics AX proxy account.
- System will ask you to backup your encrytion key, and then will some settings on the backhand.
- Now Click the ServerName/MSSQLSERVER on the left top of the reporting server and then click Stop. Then click Start to restart the server. Always check with the SQL administrator and make sure no other users are connected to the server before you restart the server.
Subscribe to:
Posts (Atom)