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 :
Finance | Project Operations, Human Resources, ...
Answered

How to add args to a menu-item button via form design

(1) ShareShare
ReportReport
Posted on by 343
I added a menu function button to one of my forms, referring to the already existing menu-item 'ReqTransNetAction'
This button is in the action pane above the form. 
 
This button is also on the EcoResProductDetailsExtended. When I click it here, it leads me to the net requirements of the item I clicked on.
 
However, when I click my button, I get the error: "item is missing".
I did check the properties for my menu button and they seem the same like the standard one on EcoResProductDetailsExtended.
 
Debugging shows the issue happens in the initFromCaller function of the ReqTransFormOverview class.
The issue is that the ReqCalc.argsItemId function call in here returns no itemId.
 
This code does the following:
 
 
  if (args.dataset())
  {
      id = fieldName2id(args.dataset(),fieldStr(InventTable,ItemId));
      if (id && args.record())
      {
          itemId = args.record().(id);
      }
      else if (id && args.lookupRecord())
      {
          itemId = args.lookupRecord().(id);
      }
      if (!itemId && args.caller())
      {
          callerForm = args.caller();
          if (callerForm && callerForm.args() && callerForm.args().record() && callerForm.args().record().TableId)
          {
              id = fieldName2id(callerForm.args().record().TableId,fieldStr(InventTable,ItemId));
              if (id)
              {
                  itemId = callerForm.args().record().(id);
              }
          }
      }
  }
  return itemId;
 
 
I am wondering, how can I add my datasource (or just the selected record in my table) to the menu-item so it is passed along as argument?
 
P.s. my code runs until callerForm && callerForm.args() && callerForm.args().record() && callerForm.args().record().TableId), to which it returns false.
 
  • Verified answer
    Martin Dráb Profile Picture
    241,643 Most Valuable Professional on at
    First of all, make sure that args.record() returns a record. If it doesn't, set the right data source to the Data Source property of the menu item button.
     
    If the table has a field called ItemId, the code above should fetch the value. If it doesn't work as expected, use the debugger to understand where is fails.
  • Superbunny Profile Picture
    343 on at
    Hey Martin,
     
    I managed to find out where the problem was while adding different datasources.
    I tried to use the datasource property before, but noticed no difference.
     
    This was because I needed to pass another table (inventTable), from which the formGrids' itemId column came.
     
    It was a bit of struggle to debug, since a lot of the data comes from function calls and not properties.
  • Superbunny Profile Picture
    343 on at
    Hey Martin,
     
    Please note that I have been trying to accept your answer, but each time I do the request times out.
     
    I just created a support request to have this fixed, but this is the third time this happens to me.
  • Martin Dráb Profile Picture
    241,643 Most Valuable Professional on at
    Unfortunately, this is a well-known bug of the forum platform that apparently still hasn't been fixed. I've done it on your behalf; it often (but not always) works for me.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 265 Super User 2026 Season 2

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 215

#3
Subra Profile Picture

Subra 177 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans