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

Announcements

No record found.

News and Announcements icon
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

  • Suggested answer
    nmaenpaa Profile Picture
    101,174 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
    241,637 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

#1
nmaenpaa Profile Picture

nmaenpaa 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans