Microsoft Dynamics AX 2012:Example of Client Server Methods in AX 2012

Hi,All

Client/Server method modifier and ‘Run On’ property of object

Client /Server

Basically these are the method modifiers use to minimized the load/traffic between client and server. These modifiers can only be used for static methods of class and table static methods. These can’t be use for instance methods because these method will be run on where the class instance method created. Also we can’t’ use these modifiers for  table methods insert, doInsert, update, doUpdate, delete, and doDelete on the Server (where the data source is).

Since we have Client tier (AX Client) and Server tier (AOS), so if we want to execute our method on client then we can set the method modifier to ‘client’ and if we want to execute the method on server than we can set the modifier to ‘server’.Also if don’t set and modifier to the method then method will be run based on the ‘RunOn’ property of the class.If the RunOn property of the class is set to ‘Called From’ then method can either be executed on client or server.

image001

// Sets the RunOn property to Client.
client static boolean myMethod()
{
    // ToDo Insert code here.
}

Above method will be run on AX client

 

// Sets the RunOn property to Server.
server static boolean myMethod()
{
    // ToDo Insert code here.
}
Above method will be run on AOS 
But we can also do this(see below) 
which apparently make the property of the method to ‘Called from’

// Sets the RunOn property to Called from.

client server static boolean myMethod()

{

// ToDo Insert code here.

}

Some Best Practices for Client/Server Modifier:

http://msdn.microsoft.com/en-us/library/aa672948.aspx

Example1(Client modifier):

We have a table called ‘JournalizingDefinition’ which has a static method ‘lookupRefCtrlJournalizingDefByModule’ which has a ‘Client’ modifier declare. Now this method will always we be used for a form lookup field on a ‘Transaction Posting Definition’ form

imapge2

Transaction Posting Definition form

image3.jp

Now on a lookup field of the form this method is being used several times for different module(see below).So basically it means that this method will never be used on Server side that’s why it is set to Client(AX Client)

image5

Example 2 (Server modifier):

We have a class ‘LedgerJournalPost’ which has a method called ‘Post’ which is apparently used when we try to ‘Post’ a journal.

image6

So it mean that this method will always be called on Server AOS for posting purposes, please let me know for any concern

also see

http://axdaily.blogspot.com/2010/02/moving-code-execution-from-client-to.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s