SAP Business One SDK – Call Custom Method from System Form Button Event

SAP Business One SDK – Call Custom Method from System Form Button Event

It is possible to call custom Method from System Button event. Set up your form type and event type filters appropriately. Then you’ll be able to attach an event handler to ItemEvent. When the handler fires, respond to events for the ItemUID of the system button you’re interested in. IN your event handlers you’ll typically have something like this:

//SAP Business One SDK - Call custom Method from Sytem Form Button Event

 public void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
 {
            BubbleEvent = true;
            var EventEnum = pVal.EventType;
            if ((pVal.FormType == 133 & pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) & (pVal.ItemUID == "1") & (pVal.Before_Action == true))
            {
                CustomMethod();
            }
}

You can find the ID of the button by turning on System Information in the ‘View’ menu and hovering over the UI element. The ID and some other information are shown in the status bar.

The “Add” and “Cancel” buttons have IDs 1 and 2 in many forms.