General X++ Development
How do I create an event handler in D365FO?
How do I create an event handler in D365FO?
1 answer
Write an answerCreate a handler method and decorate it with the event attribute.
Example for a table insert event:
final class MyEventHandlers
{
[DataEventHandler(tableStr(CustTable), DataEventType::Inserted)]
public static void CustTable_onInserted(Common _sender, DataEventArgs _e)
{
CustTable custTable = _sender as CustTable;
if (custTable)
{
// Your logic.
}
}
}Use the most specific event or extension point that matches what you need. Do not subscribe to a broad event and then add a pile of unrelated checks if there is a cleaner extension point.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer