Just a short snippet to show you how to get the DataSource object from a FormDataSourceEventHandler in D365fO because I search it in my Evernote most of the time:
FormDataSourceEventHandler(formDataSourceStr(LedgerJournalTable, LedgerJournalTable), FormDataSourceEventType::Activated)]
public static void LedgerJournalTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
LedgerJournalTable currentRecord = sender.cursor();
FormDataSource ledgerJournalTableDS