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.
// Sets the RunOn property to Client.
Transaction Posting Definition form
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.
// 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.
}
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
Transaction Posting Definition form
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)
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.
So it mean that this method will always be called on Server AOS for posting purposes.
No comments:
Post a Comment