cancel
Showing results for 
Search instead for 
Did you mean: 

UI BubbleEvent property

edy_simon
Active Contributor
0 Kudos

Hi All, 

I must be missing something simple.
I would just like to confirm the behavior of BubbleEvent Property in SAPB1 UI API

  1. On a 'Button Before Click' Event, setting bubble event = false will stop triggering the 'Button  After Click' event
  2. On a 'EditText Before Validate' Event, setting bubble event = false, will not stop 'Edit Text After Validate' event.

Is the above correct?
If it is correct, how can i stop the EditText after validate?

Regards
Edy

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi edy_simon,

I just noticed this question.

Can you please help to share the sample code which is being used and what exactly are you trying to achieve?

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi edy_simon,

Check SAP Note 1832907 for the same.

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

edy_simon
Active Contributor
0 Kudos
Hi Ankit, Thanks

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Kudos

Hi @ANKIT_CHAUHAN ,

No particular thing to achieve, just wondering if this is a bug or by design. 
AFAIK, the BubbleEvent property should prevent the system event from bubbling up to the next event.
For example, in a button BeforeItemPressed event, if I set the BubbleEvent = false, the UI API will not raise the AfterItemPressed event.

However, in a grid BeforeValidate event, even when setting the BubbleEvent = false, UI API still raise the AfterValidate event.

Below is the code i use to test 

    internal class Program
    {
        static SAPbouiCOM.Application app;
        static string formUID, grid1UID, grid2UID;


        [STAThread]
        static void Main()
        {
            try
            {
                SAPbouiCOM.SboGuiApi oGUI = new SAPbouiCOM.SboGuiApi();
                oGUI.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056");
                app = oGUI.GetApplication();
                app.ItemEvent += App_ItemEvent;

                //Create 1 form with 1 grid
                var fcp = app.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams) as SAPbouiCOM.FormCreationParams;
                string sql1 = "SELECT CAST('A' AS NVARCHAR(1))  InvDesc, '1' LineIdx, '0' LineNum UNION ALL SELECT 'A', '2', '1' UNION ALL SELECT 'A', '1', '2' UNION ALL SELECT 'A', '2', '2'";

                var newForm = app.Forms.AddEx(fcp);
                formUID = newForm.UniqueID;
                newForm.Title = "Test Grid Validate";
                newForm.Width = 650;
                newForm.Height = 750;
                var dt = newForm.DataSources.DataTables.Add($"dt1");
                dt.ExecuteQuery(sql1);
                var grid = newForm.Items.Add($"grd1", SAPbouiCOM.BoFormItemTypes.it_GRID).Specific as SAPbouiCOM.Grid;
                grid.Item.Top = 10;
                grid.Item.Left = 10;
                grid.Item.Width = 600;
                grid.Item.Height = 300;
                grid.DataTable = dt;

                newForm.Visible = true;

                System.Windows.Forms.Application.Run();
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }

        private static void App_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            try
            {
                if(FormUID == formUID && pVal.ItemUID == "grd1" && pVal.ColUID=="LineNum" && pVal.EventType== BoEventTypes.et_VALIDATE && pVal.BeforeAction)
                {
                    //Before Action
                    app.StatusBar.SetText("Before Action triggered");
                    BubbleEvent = false;
                    return; 
                }
                if (FormUID == formUID && pVal.ItemUID == "grd1" && pVal.ColUID == "LineNum" && pVal.EventType == BoEventTypes.et_VALIDATE && !pVal.BeforeAction)
                {
                    //After Action
                    app.StatusBar.SetText("After Action triggered");
                }

            }
            catch (Exception Ex)
            {
                BubbleEvent = false;
                MessageBox.Show(Ex.Message);
            }
        }
    }