web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Initialised event handler

(0) ShareShare
ReportReport
Posted on by 60

Hello,

I am trying to use form datasource(SalesParmTable) "OnInitialised" event in "SalesEditLines" form. I have created a new class and pasted the event handler code in it. 

The issue here is that I am not able to get the selected record in "SalesParmTable" buffer. Below is the code:

[FormDatasourceEventHandler(formDataSourceStr(SalesEditLines, SalesParmTable), FormDataSourceEventType::Initialized)]

public static void SalesParmTable_OnItialized(FormDataSource sender, FormDataSourceEventArgs e)

{

FormDataSource SalesParmTable_ds = sender.formRun().datasource("SalesParmTable");

SalesParmTable salesParmTable = SalesParmTable_ds.cursor();

if(salesParmTable)

info("Found");

else

info("Not Found");

Any input is highly appreciated!

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    First of all, you should already have the correct data source reference in the sender variable. There's no reason to go to the form run from that variable, and then try to go back to the data source.

    So could you try this:

    SalesParmTable salesParmTable = sender.cursor();


  • AX Ankit Profile Picture
    60 on at

    Hello Nikolaos,

    Thanks for your response. I tried your suggestion but the issue is still same. I just debugged it after the changes and I did not get any record Id in SalesParmTable.

    Any other idea?

  • Verified answer
    Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    You're using a wrong event; initialization happens before any record is fetched from database. Consider the "Active" event (or something like that) instead of "Initialized".

  • AX Ankit Profile Picture
    60 on at

    Hello Martin,

    Thanks for your response. That resolved my issue. I copied my code to Active event and it worked.  

    Thanks a lot for you help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans