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:
Subscribe to:
Posts (Atom)