Post Event in AX

Today I will demonstrate you that how to use Post Event in AX 2012.


Simple Method for Post Event

public int numberOfExpectedAttendees (int _numOfInvites, int _numOfDeclines)
{
return _numOfInvites - _numOfDeclines;
}


Post Method
static public void numberOfExpectedAttendeesEhAfter(XppPrePostArgs ppArgs)
{
int intAttendees;

intAttendees = any2Int(ppArgs.getReturnvalue());
info(strFmt("%1 = intAttendees raw, in event handler.", intAttendees));
if (0 > intAttendees)
{
intAttendees = 0;
ppArgs.setReturnValue(intAttendees);
}
}

Job to check


TestClass testClass9;int attendeeCountReturned;
testClass9 = new TestClass();

// Run a method that has an event handler that starts after the method finishes.

attendeeCountReturned = testClass9.numberOfExpectedAttendees(8, 13);

// The Infolog output displays the effect of the after-method event handler.

info(strFmt("%1 == the number of expected attendees.",attendeeCountReturned));





Comments