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

//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.

edgenbdefaultwarehouses is menuitem name.