Skip to Content
Author's profile photo Former Member

UI API For Dummies – Part 1 Menus

In the first in this blog series I will show you how to make small changes via the UI API focusing on menu related activities:


Activate a Menu Item

It’s very easy to call/activate a menu from SAP Business One. Only one line of code is required:


To find the string id required for each menu you can do the following:

  1. From the SAP Business One toolbar ensure View -> System Information is activated. When you hover over each menu in the toolbar you will find the associated menu id
  2. In the SDK Help File click on UI API -> Creating Menus -> List of Menu Item IDs for a full list of all menus


Change a Menu caption

To change the menu caption we need to access the string value of the menu and give it a new name. In this example i have changed the ‘Human Resources’ menu to ‘HR’. Again we need to access the Menu ID as we did in the previous example.

     Dim oMenus As SAPbouiCOM.Menus

     oMenus = SBO_Application.Menus

     oMenus.Item(“43544”).String = “HR”


Removing a Menu

You can remove a menu in Business One itself via the Form Settings for the Main Menu (using Visible property) but if you need to remove a menu via the UI it can be easily done. In our example we are removing the ‘Document Printing’ menu from the Sales module.

Dim oMenus As SAPbouiCOM.Menus

oMenus = SBO_Application.Menus



Adding an option to the Right Click Menu

The right click menu allows you to increase the usability of your addon. In this example i added a new entry to the Right Click menu called ‘Save as Draft’. I capture the click on the new menu event and activate the Save as Draft menu from the File menu in the toolbar. You can also do this for other menus also e.g. What’s This? help menu for an explanation of each field.


Right Click Event

Private Sub SBO_Application_RightClickEvent(ByRef eventInfo As SAPbouiCOM.ContextMenuInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.RightClickEvent

  If eventInfo.FormUID = “F_92” Then

      If (eventInfo.BeforeAction = True) Then

          Dim oMenuItem As SAPbouiCOM.MenuItem

          Dim oMenus As SAPbouiCOM.Menus

          Dim oCreationPackage As SAPbouiCOM.MenuCreationParams


              Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

              oCreationPackage = SBO_Application.CreateObject (SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

              oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

              oCreationPackage.UniqueID = “Draft”

              oCreationPackage.String = “Save as Draft”

              oCreationPackage.Enabled = True

              oMenuItem = SBO_Application.Menus.Item(“1280”) ‘Data’

              oMenus = oMenuItem.SubMenus


          Catch ex As Exception


          End Try

     End If

  End If

End Sub


Menu Event

Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent

  If pVal.MenuUID = “Draft” And pVal.BeforeAction = False Then


  End If

End Sub


In two weeks time, we will continue with the UI API for Dummies blog series. So catch you then 🙂

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Yatsea Li
      Yatsea Li

      Good job. It is prettey helpful for new begginers. Such a series of blog is much useful rather than answering the same question over again and again in Email and Forum.

      Keep moving forward. Thanks.

      Kind Regards, Yatsea

      Author's profile photo Former Member
      Former Member
      This a very nice article thanks for the insights with fundamentals. any idea on displaying crystal reports on with right click menu option.