Pre Event in AX
Today I will demonstrate you that how to use Pre Event in AX 2012.
Simple Method
public str formatWholeName(str _firstName, str _lastName)
{return _lastName + ", " + _firstName;
}
static public void formatWholeNameEhBefore(XppPrePostArgs ppArgs)
{
str firstName;
firstName = ppArgs.getArg("_firstName");
if ("Dave" == firstName)
{
ppArgs.setArg("_firstName", "David");
}
else if ("Bill" == firstName)
{
ppArgs.setArg("_firstName", "William");
}
}
str formattedWholeName;
testClass9 = new TestClass();
// Run a method that has a pre-method event handler,
// one that starts and ends before the method starts.
formattedWholeName = testClass9.formatWholeName("Dave", "Ahs");
// The Infolog displays the effect of the before-method event handler.
info(strFmt("%1 == the formatted formal name.",formattedWholeName));
Simple Method
public str formatWholeName(str _firstName, str _lastName)
{return _lastName + ", " + _firstName;
}
Pre Method
{
str firstName;
firstName = ppArgs.getArg("_firstName");
if ("Dave" == firstName)
{
ppArgs.setArg("_firstName", "David");
}
else if ("Bill" == firstName)
{
ppArgs.setArg("_firstName", "William");
}
}
Job To Run That Event
TestClass testClass9;str formattedWholeName;
testClass9 = new TestClass();
// Run a method that has a pre-method event handler,
// one that starts and ends before the method starts.
formattedWholeName = testClass9.formatWholeName("Dave", "Ahs");
// The Infolog displays the effect of the before-method event handler.
info(strFmt("%1 == the formatted formal name.",formattedWholeName));
Comments
Post a Comment