Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / To disable menu item b...
Finance forum
Suggested answer

To disable menu item button , after printing report

Posted on by 1,451
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
    Waed Ayyad 2,982 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
    Bharani Preetham Pe... 3,520 Super User 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
    Waed Ayyad 2,982 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
    Dineshkarlekar 1,451 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
    Layan Jwei 3,447 Super User 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
    CU04051814-0 170 on at
    To disable menu item button , after printing report
    fdf

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,623 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,463 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans