Skip to main content

Notifications

Community site session details

Community site session details

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

To disable menu item button , after printing report

(1) ShareShare
ReportReport
Posted on by 1,527
I have menu item button on form , which i need to disable when the  report is executed on screen  , how can i get this done , anyone have any suggestions please let me know.
 
 
Thanks,
Regards,
Dinesh
  • Suggested answer
    Waed Ayyad Profile Picture
    8,571 Super User 2025 Season 1 on at
    To disable menu item button , after printing report
    Hi,

    Is your issue resolved? If yes, mark the answers that helped you as verified.


    Thanks
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    To disable menu item button , after printing report
    Seems you have already a Printed status in CustInvoiceJour. So in the form datasource init method, get the menubuttoncontrol and set the enabled method in such a way if it is printed then no and vice versa. if the code isn't getting triggered as expected change the logic to active of form datasource.
  • Suggested answer
    Waed Ayyad Profile Picture
    8,571 Super User 2025 Season 1 on at
    To disable menu item button , after printing report
    Hi,
     
    You can call the form control even its Auto declaration property is set to No in the case on form extension. In your code try to call button name and disable it. I noticed something on your code you are trying to update the current record, but you selected the wrong buffer. 
     
     
    class DTCustInvoiceJourForm_SalesInvoiceDTIsPrinted_Eventhandler
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        [FormControlEventHandler(formControlStr(CustInvoiceJournal, HYD_SalesInvoiceReport), FormControlEventType::Clicked)]
        public static void HYD_SalesInvoiceReport_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            Args args = new Args();
            FormMenuButtonControl  callerButton = sender as  FormMenuButtonControl;
            FormRun form = callerButton.formRun();
            FormDataSource CustInvoiceJour_ds = form.dataSource(formDataSourceStr(CustInvoiceJournal,CustInvoiceJour)) as FormDataSource;
            CustInvoiceJour custInvoiceJour,custInvoiceJourLoc;
            custInvoiceJour = CustInvoiceJour_ds.cursor();
            args.record(custInvoiceJour);
            args.parm(custInvoiceJour.SalesId);
    
            if (custInvoiceJour.SalesId)
            {
                // Sales order invoice
                new MenuFunction(menuitemOutputStr(EHISalesInvoiceReport), MenuItemType::Output).run(args);
                //callerButton.enabled(false);
               YourButtonName.enabled(false);
               // select forupdate custInvoiceJour;
                custInvoiceJour.selectForUpdate(true);
                ttsbegin;
                custInvoiceJour.DTIsPrinted = NoYes::Yes;
                custInvoiceJour.doupdate();
                ttscommit;
    
            }
        }
    }
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Dineshkarlekar Profile Picture
    1,527 on at
    To disable menu item button , after printing report
    hi ,
    thanks for reply this menu item button prints the report ,
     i have written the code on on clicked event of this button , is it possible to fetch the form control if its auto declaration property is false , but the button is not getting disable report is getting generated ,
    my code is below, please let me know if my code is missing something , and the auto declaration property for this button is set to no . will it create any issue .
    class DTCustInvoiceJourForm_SalesInvoiceDTIsPrinted_Eventhandler
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        [FormControlEventHandler(formControlStr(CustInvoiceJournal, HYD_SalesInvoiceReport), FormControlEventType::Clicked)]
        public static void HYD_SalesInvoiceReport_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            Args args = new Args();
            FormMenuButtonControl  callerButton = sender as  FormMenuButtonControl;
            FormRun form = callerButton.formRun();
            FormDataSource CustInvoiceJour_ds = form.dataSource(formDataSourceStr(CustInvoiceJournal,CustInvoiceJour)) as FormDataSource;
            CustInvoiceJour custInvoiceJour,custInvoiceJourLoc;
            custInvoiceJour = CustInvoiceJour_ds.cursor();
            args.record(custInvoiceJour);
            args.parm(custInvoiceJour.SalesId);
    
            if (custInvoiceJour.SalesId)
            {
                // Sales order invoice
                new MenuFunction(menuitemOutputStr(EHISalesInvoiceReport), MenuItemType::Output).run(args);
                callerButton.enabled(false);
                select forupdate custInvoiceJour;
                ttsbegin;
                custInvoiceJour.DTIsPrinted = NoYes::Yes;
                custInvoiceJour.doupdate();
                ttscommit;
    
            }
        }
    }
    thanks,
    Regards,
    Dinesh
     
  • Layan Jwei Profile Picture
    7,865 Super User 2025 Season 1 on at
    To disable menu item button , after printing report
    Hi Dinesh,

    Is this a custom form you created? if yes,  then in general, to disable a menu item, you just need to set "auto declaration" property as true for the menu item. Then write code as this: MenuItemName.enabled(false);
     
    I didn't get this sentence " that u need to disable the menu item if report is executed on screen" can you please explain more clearly?

    what does this menu item button have to do with the report?



    Thanks,
    Layan Jweihan
  • CU04051814-0 Profile Picture
    on at
    To disable menu item button , after printing report
    fdf

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Martin Dráb Profile Picture

Martin Dráb 601 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 416

#3
Adis Profile Picture

Adis 384 Super User 2025 Season 1

Product updates

Dynamics 365 release plans