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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Retrieving selected row in the grid in Form when form control button is clicked.

(0) ShareShare
ReportReport
Posted on by 1,645

Hi,

I added new button “Back to draft” in the Approval menu in the Journal. Basically what it has to do it when the user click that button, the journal which is already reported as ready should be reverted back so that user can amend the journal.

The problem I am having now is I am not being able to figure out the way to retrieve the selected row in the journal.

  /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(LedgerJournalTable, BackToDraft2), FormControlEventType::Clicked)]
    public static void BackToDraft2_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        FormRun                         formrun = sender.
        Object                          LedgerJournalTable_DS = FormRun.dataSource(formDataSourceStr(LedgerJournalTable,LedgerJournalTable));
        LedgerJournalTable              localLedgerJournalTable =   LedgerJournalTable_DS.getFirst() as LedgerJournalTable;
        localLedgerJournalTable.ReportedAsReadyBy = '';
        LedgerJournalTable_DS.research();
    }

0511.Capture.PNG

Here is the code which just retrieves the first row in the data source but I need to retrieve the selected row in the grid so that I can change the status for that particular record. How would I do that using event handling? 

Thank you,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    239,678 Most Valuable Professional on at

    Why don't you simply use a menu item button and receive the record in args.record() as usual?

    If you insist on your design, try something like sender.dataSourceObject().cursor().

  • Tony Mok Profile Picture
    577 on at

    I know that the question is almost a year ago, but I want to share my solution for the programmer who is looking for.

    LedgerJournalTable ledgerJournalTable;
    
    FormDataSource LedgerJournalTable_DS = sender.formRun().dataSource("LedgerJournalTable");
    
    ledgerJournalTable = LedgerJournalTable_DS.cursor();


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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans