最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Dynamics AX 2012 R2 : XppPrePostArgs changes

网络文摘 Kenny Saelen 2197浏览

Amongst many other changes made in Microsoft Dynamics AX 2012 R2, there has been soms changed to the XppPrePostArgs class too. But before you even read further, please also have a good read through a series of posts made by Joris Degruyter. The series give a nice overview of using models and events to make you code more upgradable. If there was a bible written for AX, this would be one of the first commandments!

In the series of post, Joris explains the use of the XppPrePostArgs class to fetch arguments you want to use in your event handler class. To get the FieldId from the args when the validateField method was triggered, the following code was used:

if(_args.getArg(_args.args().fieldName(1)) == FieldNum(CustTable, DMProjId)

Well, since R2, the XppPrePostArgs class has been modified to extend object instead of XppEventArgs. (MSDN: http://msdn.microsoft.com/en-us/library/xppprepostargs.aspx)
One of the concequences is the absence of the args() method. So when you want to do the same thing as above, you now have to use the following code (it’s a bit simplified and less ugly) :

if(_args.getArgNum(1) == FieldNum(CustTable, DMProjId)