cancel
Showing results for 
Search instead for 
Did you mean: 

Record change event

Former Member
0 Kudos

Dear SAP B1 SDK experts,

I am writing an Add-on for SAP B1 8.81 in C#.

I am trying to catch an event when the user navigates from one record to another in a Sales Order form.

Let's assume that I have two Sales Orders, numbers 10000001 and 10000002.

Let's assume that I am positioned in the record 10000001.

When I click the 'NEXT' button, the form loads to the 10000002.

The event has to be implemented in such a way that I retrieve the next record, that is, the 10000002.

All the implementations I tried only retrieves the information of the currently loaded record, not the next record. For example, the event et_VALIDATE is triggered when changing the record, but it is only aware of the 10000001. Other events such as et_CLICK (an the rest related to mouse clicks) are triggered quite often, not necessarily when the form jumps to the next record, so I am not sure whether the record has changed or not.

Other events related with forms seem to be of no use for that particular requirement.

I can implement a workaround for this, but seems to be quite hacky. For example, I can implement a method to be called  for each et_ALL_EVENTS, and to save the ID of the current record in an array, so I can compare whether the ID changed and thus to detect the change. The array may be quite complex because many instances of the form can be opened at the same time, and I also have to do a similar thing for Purchase Order forms.

I always try to avoid these kind of solutions. I wonder if anyone knows a simpler and more elegant way to resolve the issue.

Hope that makes sense.

Best regards.

N

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

Hi Nicolas,

If I understood your problem, you need catch the event when other register is loaded in the Form. You can implement FormDataEvent and get the EventType et_FORM_DATA_LOAD. Every time that a new register is loaded in the Form, this event is fired.

Try something like this:


        static void FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)

        {

            BubbleEvent = true;

            if (BusinessObjectInfo.FormTypeEx == "put sales order form type" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD)

            {

                //inserts your code

            }

        }

But if you need catch the click event in next, previous, last and first button of menu , you need implement the MenuEvent like this sample:


        static void MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent)

        {

            BubbleEvent = true;

            if (pVal.BeforeAction)

            {

                if (pVal.MenuUID == "1290") //First Data Record

                {

                 

                }

                if (pVal.MenuUID == "1288") //Next Record

                {

                }

                if (pVal.MenuUID == "1289") //Previous Record

                {

                }

                if (pVal.MenuUID == "1291") //Last Data Record

                {

                }

            }

        }

Hope it helps.

Regards,

Diego

Former Member
0 Kudos

Thanks Diego,

Seems to be quite sensible. I'll give it a go.

Best regards.

N

Answers (0)