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

How to pass records to another form once menu item button clicked

(0) ShareShare
ReportReport
Posted on by 1,909
Dears,
 
I have main form called ProcCategoryHierarchyManagement with some records and I already capture those records. Now I need to send that records to Form B. Please find my code below and advice how can I get the records in from B.
 
For Form ProcCategoryHierarchyManagement eventHandler with class.
 class DAWEcoResCategroy
{
    
   
    /// <summary>
    ///
    /// </summary>
    /// <param name=/sender/></param>
    /// <param name=/e/></param>
    [FormControlEventHandler(formControlStr(ProcCategoryHierarchyManagement, DAWItemCategory), FormControlEventType::Clicked)]
    public static void DAWItemCategory_OnClicked(FormControl sender, FormControlEventArgs e)
    {
         Args args = new Args();
       
        EcoResCategoryNamedHierarchyRole namedHierarcyRole;
        FormRun             element       = sender.formRun();
        FormControl         category = element.design(0).controlName(/EcoResCategory_Name/);
    
        namedHierarcyRole = EcoResCategoryNamedHierarchyRole::Procurement;
      
        args.parm(category.valueStr());
       
        info(strfmt(/categoryHierarchy %1/,EcoResCategoryHierarchyRole::getHierarchiesByRole(namedHierarcyRole).CategoryHierarchy));
        info(strfmt(/Category Name%1/, category.valueStr()));
    
    }
 
Form B form init()
 
public void init()
    {
        str 20 _category;
        super();
        if(element.args().menuItemName() == menuItemDisplayStr(DAWItemCategory))
        {
         _category = element.args().parm();
   
            EcoResCategory_Name.text(_category);
              
        }
    }
 
    

 
}
 
I have the same question (0)
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,811 Super User 2026 Season 1 on at
    Hi,
     
    look at this exemple :
    MenuFunction    menuFunction;
    Args            args = new Args();
    
    args.record(...);   // record
    args.parm(...);     // param
    
    menuFunction = new MenuFunction(menuitemDisplayStr(DAWItemCategory), MenuItemType::Display);
    menuFunction.run(args);
    Best regards,
    Mohamed Amine MAHMOUDI
  • Verified answer
    Martin Dráb Profile Picture
    240,196 Most Valuable Professional on at
    You don't need any code to pass the value, therefore throw away your event handler of clicked(). Create a menu item for FormB, drag it to your extension of ProcCategoryHierarchyManagement to create a menu item button and set its Data Source property to EcoResCategory. When you click the button, it's open FormB and pass the active EcoResCategory record there.
     
    If you have EcoResCategory at the first data source of FormB, it'll automatically filter the data source and therefore maybe you don't need any code at all.
     
    If you need to get the record in FormB, call this.args().record() to get it.
  • Faqruddin Profile Picture
    1,909 on at
    Thanks Martin. Its works and looks very easy to pass the records between forms.
     
    Hi Amine,
     
    Previously I used your approach but it open the from B twice after I click and not working properly. Thanks for you suggestion.

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

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 382 Super User 2026 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 265 Most Valuable Professional

#3
Subra Profile Picture

Subra 262

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans