web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to hide System Defined Office Button(#SystemDefinedOfficeButton) from D365 form

(0) ShareShare
ReportReport
Posted on by

My requirement is to hide these two buttons(#SystemDefinedOfficeButton and #SystemDefinedAttachButton) on the base of a toggle button.

3681.pastedimage1652202484048v1.png

//Currently I'm writing my code in the init method of form. It is working perfect and successfully hiding attachment button.

[ExtensionOf(formStr(VendTable))]
final class VendTableForm_Extension
{
public void init()
{
#SysSystemDefinedButtons

next init();

FormCommandButtonControl attachButton= this.control(this.controlId(#SystemDefinedAttachButton)) as FormCommandButtonControl;
attachButton.visible(false);
}

}

//But when I'm adding below code for the office button it is giving me error.

[ExtensionOf(formStr(VendTable))]
final class VendTableForm_Extension
{
public void init()
{
#SysSystemDefinedButtons

next init();

FormCommandButtonControl attachButton= this.control(this.controlId(#SystemDefinedAttachButton)) as FormCommandButtonControl;
attachButton.visible(false);

FormCommandButtonControl OfficeButton= this.control(this.controlId(#SystemDefinedOfficeButton)) as FormCommandButtonControl;
OfficeButton.visible(false)
}

}

Scree shot of error is attached for the reference. 

5582.pastedimage1652203892300v2.png

edgenbdefaultwarehouses  is menuitem name.

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Ahmad,

    This code should work for you in hiding the button.

    void init()
        {
            #SysSystemDefinedButtons
    
            next init();
    
            FormMenuButtonControl officeButton= this.control(this.controlId(#SystemDefinedOfficeButton)) as FormMenuButtonControl;
            officeButton.visible(false);
        }

  • Ahmad Hassan Profile Picture
    on at

    Yes, that's my question why is it giving me error I tested it for the couple of forms and same error in all cases.

    5684.pastedimage1652219381921v1.png

    I'm unable to open form when I write code for the office button. On the other hand it is working perfect in case of attachments button.

    Can you please share the screenshot of your form if you successfully hide office button using this code.

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Ahmad,

    Please check the code I used. You will need to use FormMenuButtonControl instead of FormCommandButtonControl. Here is a screenshot of the vendor form after making this change

    2538.pastedimage1652220952469v1.png

  • Ahmad Hassan Profile Picture
    on at

    Thanks a lot Gunjan Bhattacharyya!

    You really made my day.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans