Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to add args to a m...
Finance forum
Unanswered

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

Posted on by 141
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.
 
  • Martin Dráb Profile Picture
    Martin Dráb 227,971 Super User 2024 Season 2 on at
    How to add args to a menu-item button via form design
    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.
  • Superbunny Profile Picture
    Superbunny 141 on at
    How to add args to a menu-item button via form design
    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.
  • Superbunny Profile Picture
    Superbunny 141 on at
    How to add args to a menu-item button via form design
    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.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 227,971 Super User 2024 Season 2 on at
    How to add args to a menu-item button via form design
    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.

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Mohana Yadav!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,115 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,971 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans