Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to get selected data from a Grid containing a temporary table

(0) ShareShare
ReportReport
Posted on by 15

Hi all, for AX 2009, I have a grid that is populated with the contents of a temporary table. 

I then placed a button beside the grid. 

On the clicked method on that button, how do I get the currently selected record on the grid? Or more specifically, how do I get one of the fields from the currently selected record on the grid?

Multi-select is not enabled on the grid, I want to select a single record only.

Thanks so much!

  • Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How to get selected data from a Grid containing a temporary table

    Typhoon Please check Girish's suggestion and try to access by DataSourceName.FieldName. If it works then No need of using form controls, otherwise you already have a solution.

    Please mark answer/s verified so it can help someone in Future.

  • Suggested answer
    Typhoon Profile Picture
    15 on at
    RE: How to get selected data from a Grid containing a temporary table

    Thanks Mohit, I got it working now.

    The grid is called MyGrid.

    The fields on the grid are ID, Name, and Active.

    I set Auto Declaration to Yes for all the fields on the grid.

    Then I could say on the clicked method (after the super):

    str selectedName;

    selectedName = Name.valueStr();

    It then retrieved the name correctly into the string.

    Thanks for your help!

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: AX 2009 - How to get selected data from a Grid containing a temporary table

    Hi Typhoon,

    If you want to get the current record from the grid you can use DataSourceName.FieldName to get the particular field.

    This will return the current selected record from the grid.

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: AX 2009 - How to get selected data from a Grid containing a temporary table

    Hi, You can get the field value of selected record by setting AutoDeclaration property of form control to Yes and after super in clicked method of button get value like below. (I have checked in D365 F&O but should work in AX 2009 as well). If the type of control is not string then valueStr will not work. Let us know if still issues

    /// 
    ///
    /// 
    public void clicked()
    {
        super();
    
        ItemId itemIdValue = SalesLineTmp_ItemId.valueStr();
    }
    

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,013 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans