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)

Get the datasource from caller MenuItemButton

(0) ShareShare
ReportReport
Posted on by 453

Hi all

I have a form with 3 Action MenuItemButtons. In that form I have 3 different datasources. 

The menuItems call the same class.

I have set the datasource property for all 3 menuItems. 

In the class main menu I have this code:

pdp = args.caller().dataSource(0);


The problem is that it always take the same datasource no matter which button is clicked. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    That's correct; your code asks for the first datasource of the form. Use this instead:

    args.record().dataSource()
  • Mehdi26 Profile Picture
    453 on at

    Hi Martin

    I did that. But it still takes the same datasource.

  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    It's the datasource bound to the menu item button. It seems that you set the DataSource property to a different datasource than you actually want.

  • Mehdi26 Profile Picture
    453 on at

    The datasources of the menuitems are set to their respective datasources. I don't know what can be wrong.

  • Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    How are you checking whether it's the right object? Can you please look at which table you get when you call args.record()?

  • Mehdi26 Profile Picture
    453 on at

    The table in args.record() is always the sourcetable of the first datasource. 

    I check it with this code:

    if(args.caller()!=null)
    {
      fds = args.caller().dataSource();
      record = fds.getFirst(1);
      bIsMultiSelect=1;
    }
    if(record.RecId==0)
    {
      if(args.record()!=null)
      record=args.record();
    }


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

    All right, this is the problem. Your code is wrong; it will never call args.record() is the first data source has a record.

    Throw away everything except of record=args.record().

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