When you run a query and restore values at Axapta you would be see values are not you restored. Reason would be "last used query" at "select query". To prevent this effect you have to use SysQueryRun instead of QueryRun. SysQueryRun is extended version of QueryRun.
This code prevents "last used query":
mySysQueryRun.promptLoadLastUsedQuery(false);
3 Eylül 2015 Perşembe
2 Eylül 2015 Çarşamba
Axapta - Transfer order partial receive
This's so easy with a way which I learned from a forum page :
inventTranstransferLine.QtyReceiveNow = 50;
When you post the transfer order, your 50 pcs items will be receive.
inventTranstransferLine.QtyReceiveNow = 50;
When you post the transfer order, your 50 pcs items will be receive.
Etiketler:
accept,
AX,
AXAPTA,
partial,
qtyreceivenow,
receive,
transfer order
27 Ağustos 2015 Perşembe
AXAPTA - Save query to a table field and restore than
I used Mirko Bonello's blog for this sample.
Create a container field at table. Mine is InventTableQuery:
void createAndSaveQueryInTable()
{
QueryRun SysqueryRun;
;
if (this.InventTableQuery)
queryRun = new QueryRun(this.InventTableQuery);
else
queryRun = new QueryRun(queryStr('InventTable'));
qrun.promptLoadLastUsedQuery(false);
if (queryRun.prompt())
this.InventTableQuery = queryRun.pack();
}
We used SysQueryRun instead for QueryRun and set qrun.promptLoasLastUsedQuery(false) for don't screw like me because of "Why I get same query values for every record?" question... :)
Create a container field at table. Mine is InventTableQuery:
void createAndSaveQueryInTable()
{
QueryRun SysqueryRun;
;
if (this.InventTableQuery)
queryRun = new QueryRun(this.InventTableQuery);
else
queryRun = new QueryRun(queryStr('InventTable'));
qrun.promptLoadLastUsedQuery(false);
if (queryRun.prompt())
this.InventTableQuery = queryRun.pack();
}
We used SysQueryRun instead for QueryRun and set qrun.promptLoasLastUsedQuery(false) for don't screw like me because of "Why I get same query values for every record?" question... :)
AXAPTA - Write text file
TextIo textIo;
str fileName;
FileIOPermission fioPermission;
#File
;
fileName = "c:\\myfolder\\test.txt"
fioPermission = new FileIOPermission
(fileName ,"RW");
fioPermission.assert();
if (WINAPI::fileExists(fileName))
{
WINAPI::deleteFile(fileName);
}
textIo = new TextIo(fileName, #IO_WRITE);
textIo.write("test 12");
textIo.write("test 34");
textIo = null;
CodeAccessPermission::revertAssert();
}
str fileName;
FileIOPermission fioPermission;
#File
;
fileName = "c:\\myfolder\\test.txt"
fioPermission = new FileIOPermission
(fileName ,"RW");
fioPermission.assert();
if (WINAPI::fileExists(fileName))
{
WINAPI::deleteFile(fileName);
}
textIo = new TextIo(fileName, #IO_WRITE);
textIo.write("test 12");
textIo.write("test 34");
textIo = null;
CodeAccessPermission::revertAssert();
}
19 Ağustos 2015 Çarşamba
AXAPTA - Execute direct SQL statement
The sample given at that blog
worked for me good. Unfortunately in sample at this blog and others always read just one field from query. I got an error about index when try to read fields more than one. Later I learned I have to read fields in ascending numeric order from a Microsoft's page . Run method from server side. In the other case you wold be get a security error. For insert ve delete (however this's not an advicable way for Axapta tables)
instead of executeQuery you can use executeUpdate.
public server static InventRep FillSQL(DatePhysical _DatePhysical = today())
{
InventRep InventRep;
Connection connection;
Statement statement;
str query,dateStr;
Resultset resultSet;
;
dateStr = date2str(_DatePhysical,321,dateday::Digits2,dateseparator::None,
datemonth::Digits2,dateseparator::None,dateyear::Digits4);
connection = new Connection();
statement = connection.createStatement();
query =
"select ITEMID,SUM(QTY)"+
"from INVENTTRANS "+
"where DATAAREAID='TST'"+
"and DATEPHYSICAL <='"+dateStr+"' "+
"group by ITEMID "+
"having SUM(QTY) <>0";
new SqlStatementExecutePermission(query).assert();
resultSet = statement.executeQuery(query);
while(resultSet.next())
{
//---- fields shoud be in numeric order ------
InventRep.ItemId = resultSet.getString(1);
InventRep.Qty = resultSet.getReal(2);
InventRep.insert();
}
CodeAccessPermission::revertAssert();
}
public server static InventRep FillSQL(DatePhysical _DatePhysical = today())
{
InventRep InventRep;
Connection connection;
Statement statement;
str query,dateStr;
Resultset resultSet;
;
dateStr = date2str(_DatePhysical,321,dateday::Digits2,dateseparator::None,
datemonth::Digits2,dateseparator::None,dateyear::Digits4);
connection = new Connection();
statement = connection.createStatement();
query =
"select ITEMID,SUM(QTY)"+
"from INVENTTRANS "+
"where DATAAREAID='TST'"+
"and DATEPHYSICAL <='"+dateStr+"' "+
"group by ITEMID "+
"having SUM(QTY) <>0";
new SqlStatementExecutePermission(query).assert();
resultSet = statement.executeQuery(query);
while(resultSet.next())
{
//---- fields shoud be in numeric order ------
InventRep.ItemId = resultSet.getString(1);
InventRep.Qty = resultSet.getReal(2);
InventRep.insert();
}
CodeAccessPermission::revertAssert();
}
12 Ağustos 2015 Çarşamba
AX 2009 - Ride off warning message when report doesn't fit to screen
If Axapta reports don't fit in screen warn you.
If this message bothers you, put this in report init method:
this.printJobSettings().suppressScalingMessage(true);
There had be a way to ride off this message all of your reports. Put these lines into SysReportRun classes Run method before super():
if(this.printJobSettings())
this.printJobSettings().suppressScalingMessage(true);
this.printJobSettings().suppressScalingMessage(true);
There had be a way to ride off this message all of your reports. Put these lines into SysReportRun classes Run method before super():
if(this.printJobSettings())
this.printJobSettings().suppressScalingMessage(true);
5 Ağustos 2015 Çarşamba
AX 2009 - Consume web service with TC ID number test sample
I rewrite sample which I wrote for 2012. When I write the service I used Microsoft'un white page about consume web services in 2009. White page written for a web service which is not avaliable than but anyway worked.
First run AOT->References->Add service reference:
Write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to WSDL URL field.
I wrote TCSorgula to .NET code namespace field. I left reference name field with default written TCSorgula value.
After I wrote this method:
public server static boolean Sorgula(Int64 _TCID,str _name,str _surname, int _birthDate, boolean _interActive = false)
{
TCSorgula.KPSPublicSoapClient cl;
boolean ret;
System.Exception ex;
str st;
;
try
{
new InteropPermission(InteropKind::ClrInterop).assert();
cl = new TCSorgula.KPSPublicSoapClient("KPSPublicSoap");
ret = cl.TCKimlikNoDogrula(_TCID,_name,_surname,_dogumYili);
CodeAccessPermission::revertAssert();
}
catch(Exception::CLRError)
{
exceptionTextFallThrough();
}
if (_interActive)
{
if (ret)
info("TC ID verified!..");
else
warning("Failed TC ID verification!..");
}
return ret;
}
My job for run code:
static void TCKimlikTest(Args _args)
{
;
TCKimlik::Sorgula(11111111111,"METİN","EMRE",1911,true);
}
TC ID verification service returns false when name or birthdate is wrong in case invalid ID strangely run exception. I was catching this case in AX 2012 with search "T.C. Kimlik No alanına girdiğiniz değer geçerli bir T.C. Kimlik Numarası değildir" value in return error string. Unfortunately I failed this with 2009. So I can just catch correct ID or invalid ID/failed service.
If VS doesn't installed you can install .NET framework SDK.
First run AOT->References->Add service reference:
Write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to WSDL URL field.
I wrote TCSorgula to .NET code namespace field. I left reference name field with default written TCSorgula value.
After I wrote this method:
public server static boolean Sorgula(Int64 _TCID,str _name,str _surname, int _birthDate, boolean _interActive = false)
{
TCSorgula.KPSPublicSoapClient cl;
boolean ret;
System.Exception ex;
str st;
;
try
{
new InteropPermission(InteropKind::ClrInterop).assert();
cl = new TCSorgula.KPSPublicSoapClient("KPSPublicSoap");
ret = cl.TCKimlikNoDogrula(_TCID,_name,_surname,_dogumYili);
CodeAccessPermission::revertAssert();
}
catch(Exception::CLRError)
{
exceptionTextFallThrough();
}
if (_interActive)
{
if (ret)
info("TC ID verified!..");
else
warning("Failed TC ID verification!..");
}
return ret;
}
My job for run code:
static void TCKimlikTest(Args _args)
{
;
TCKimlik::Sorgula(11111111111,"METİN","EMRE",1911,true);
}
TC ID verification service returns false when name or birthdate is wrong in case invalid ID strangely run exception. I was catching this case in AX 2012 with search "T.C. Kimlik No alanına girdiğiniz değer geçerli bir T.C. Kimlik Numarası değildir" value in return error string. Unfortunately I failed this with 2009. So I can just catch correct ID or invalid ID/failed service.
If VS doesn't installed you can install .NET framework SDK.
Kaydol:
Kayıtlar (Atom)