How to: Run a Class on the AOS
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
In Microsoft Dynamics AX, you can specify whether a class, class instance, or class method will execute on the Application Object Server (AOS) or the client. This topic describes where classes and class static methods are run and how to change the location of where a class runs.
Classes have a property called RunOn with the following values:
Client
Called from (default setting)
Server
Objects created from the class exist at the location specified. For example, if the RunOn property for a class is set to Called from, the object will run where the code instantiating the object is running.
Classes that extend or inherit from another class also inherit the RunOn property. If the inherited RunOn property value is set to Client or Server, it cannot be modified. If the inherited RunOn property is set to Called from, it can be modified in the property settings for the class.
By default, class and table static methods run in the same location as the class object. To modify the default setting, you can add client or server, or both, to the class static method declaration. When the class object is set to client or server, you can add both client and server to the method declaration to set the RunOn property of a static method to Called from.
For more information, see Application Object RunOn Property Overview.
To run a class on the AOS
In the Application Object Tree (AOT), expand the Classes node.
In the Classes node, right-click the class template that you want to run on the AOS, and then click Properties.
In the Properties sheet, set the RunOn property to Server.
In the AOT, right-click the modified class, and then click Save.
To modify the RunOn property of a class static method
In the AOT, expand the Classes node, and then expand the class that contains the static method that you want to modify.
Right-click the static method that you want to modify, and then click Edit. The Class Editor window opens.
In the Class Editor, enter one of the following static method declaration modifiers.
// Sets the RunOn property to Called from.
client server static boolean myMethod()
{
// ToDo Insert code here.
}
\- or -
// Sets the RunOn property to Client.
client static boolean myMethod()
{
// ToDo Insert code here.
}
\- or -
// Sets the RunOn property to Server.
server static boolean myMethod()
{
// ToDo Insert code here.
}
- In the AOT, right-click the modified class, and then click Save.
See also
Developing Applications Using the AOS
Best Practices: Application Object Server (AOS)
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.