Before a record in AX gets updated an external application gets started. This external application is able to do additional update on the same record in AX by using AIF. As the performance of the external route is slow, an additional check is needed to start this process only if needed.
So what do we have?
A. Do I need to compare this with this.orig() before or after super?
B. Do I need to call this external application before or after super?
If we call the external application before super, AX will complain that another user has updated the record. So we have to do it after super. Fine, but what happens…. After super the original record gets equal to the current record. Ouch so the difference between the record and the original record only exists before super. The solution is to make a local buffer variable in the update method that references the original record before calling super. This buffer will still be used after calling super.
Example:
void update()
{
CustTable ctBuffer = this.orig();
Super();
If(this.name != ctBuffer.name)
//call external application
}
This blog is about daily challenges we normally faced in Dynamics 365 and Dynamics AX development.
Wednesday, August 5, 2009
Tuesday, August 4, 2009
AX 2009 TraceParser
This is very useful link that give some in depths about TraceParser
1. TraceParser Video Training Part I: Installation.
2. TraceParser Video Training Part II: Configuration, Collection and Importing.
1. TraceParser Video Training Part I: Installation.
2. TraceParser Video Training Part II: Configuration, Collection and Importing.
Monday, August 3, 2009
Where do you want your code to run today
Much of the X++ code you write can run on either the Application Object Server, or the Client. The client can be the Win32 client, or BC.NET for Enterprise Portal. MorhpX generally will not direct your code to run on a specific tier, but you as an application developer can control it.
Whether code runs on the server or on the client has performance and security implications, and should be given careful consideration as a part of design. Occasionally it will be correct to methods run on either tier, but usually this is not the case.
As MS move forward implementing tasks in upcoming release, developers will identify which resources to grant access to for a given task. These resources include tables/fields and server entry points. A server entry point is a specially decorated method that runs on the server. Tables/fields accessed inside this server entry point need NOT be identified with the task, greatly reducing the complexity and effort required to implement the task. If the server entry point is NOT executed on the server, then table/field access is still validated, and will fail if the code accesses a table/field that is not included with the task.
So, in short:
Set the RunOn AOT property to Server or Client for new classes, unless you have a reason to leave the default
Include considerations about where the code runs in your design, and look for it when reviewing design documents
Declare static class methods, table static and instance methods with either the "server" or the "client" keyword, unless you have a reason not to
Look for ways to limit direct table and field access in form methods, try to move this into a class
This page MSDN describes where methods run:
http://msdn.microsoft.com/en-us/library/aa891949.aspx. Additional information to cover more object types at http://msdn.microsoft.com/en-us/library/aa634829.aspx.
Whether code runs on the server or on the client has performance and security implications, and should be given careful consideration as a part of design. Occasionally it will be correct to methods run on either tier, but usually this is not the case.
As MS move forward implementing tasks in upcoming release, developers will identify which resources to grant access to for a given task. These resources include tables/fields and server entry points. A server entry point is a specially decorated method that runs on the server. Tables/fields accessed inside this server entry point need NOT be identified with the task, greatly reducing the complexity and effort required to implement the task. If the server entry point is NOT executed on the server, then table/field access is still validated, and will fail if the code accesses a table/field that is not included with the task.
So, in short:
Set the RunOn AOT property to Server or Client for new classes, unless you have a reason to leave the default
Include considerations about where the code runs in your design, and look for it when reviewing design documents
Declare static class methods, table static and instance methods with either the "server" or the "client" keyword, unless you have a reason not to
Look for ways to limit direct table and field access in form methods, try to move this into a class
This page MSDN describes where methods run:
http://msdn.microsoft.com/en-us/library/aa891949.aspx. Additional information to cover more object types at http://msdn.microsoft.com/en-us/library/aa634829.aspx.
Tuesday, July 21, 2009
Iterate all records from grid
To iterate all record from a grid is accomplished by :
VendOutPaymForParams_FI exportSetupLocal;
for (exportSetupLocal = exportSetup_ds.getNext();exportSetupLocal;exportSetupLocal=exportSetup_ds.getNext())
{
B....
}
VendOutPaymForParams_FI exportSetupLocal;
for (exportSetupLocal = exportSetup_ds.getNext();exportSetupLocal;exportSetupLocal=exportSetup_ds.getNext())
{
B....
}
Tuesday, July 14, 2009
Getting rid of the "Loss of precision" warning message
A question came up at today's webinar where a developer had a (presumably legitimate) reason to cast a real value into an integer value. The X++ language does not allow explicit casting (there's no support for it in the language), but the compiler will do its best to satisfy the user and do the conversion on its own. In this case, however, it issues a warning message, lest this is not what the user wanted.
One solution is to use the anytype type to hold the vaue for conversion and then using the any2int function, as shown below:
static void Job47(Args _args)
{
real r = 3.13;
int i = r; // Warning is issued here
anytype a;
a = r; // Assign to an anytype variable...
i = any2int(a); // ... and back into an int
print r;
print i;
pause;
}
This should be packaged into a function, maybe called int RealToInt(real arg).
Another way would be doing the conversion in managed code (through the System.Convert::ToInt32(object) method), but the performance will not be as good because of the marshalling that needs to take place.
One solution is to use the anytype type to hold the vaue for conversion and then using the any2int function, as shown below:
static void Job47(Args _args)
{
real r = 3.13;
int i = r; // Warning is issued here
anytype a;
a = r; // Assign to an anytype variable...
i = any2int(a); // ... and back into an int
print r;
print i;
pause;
}
This should be packaged into a function, maybe called int RealToInt(real arg).
Another way would be doing the conversion in managed code (through the System.Convert::ToInt32(object) method), but the performance will not be as good because of the marshalling that needs to take place.
Forthcoming changes to the X++ language
Very informative link for new X++ release
http://blogs.msdn.com/x/archive/2009/06/29/forthcoming-changes-to-the-x-language.aspx
http://blogs.msdn.com/x/archive/2009/06/29/forthcoming-changes-to-the-x-language.aspx
Monday, July 6, 2009
How to get all changes done in usr layer into project.
Create a new project and open the project.
Press Ctrl+f3 or click on the icon advance filter/sort on the toolbar of the
project, a dialog with name project filter will be opened.
In project filter, select append and aot.Click select for the query dialog
to open enter the query layer usr in the utillevel range and click Ok to
close query dialog .
Click Ok to close the project filter dialog. This will create a project with the objects of usr layer.
Press Ctrl+f3 or click on the icon advance filter/sort on the toolbar of the
project, a dialog with name project filter will be opened.
In project filter, select append and aot.Click select for the query dialog
to open enter the query layer usr in the utillevel range and click Ok to
close query dialog .
Click Ok to close the project filter dialog. This will create a project with the objects of usr layer.
Subscribe to:
Posts (Atom)