cancel
Showing results for 
Search instead for 
Did you mean: 

Updating Matrix On a System Form

former_member183373
Active Participant
0 Kudos

Hello Everyone,

I am trying to update a matrix that exist in a SAP Business One system form. I open the form in SAP Business One Studio and than create project in Visual Studio 2010 to work on the system form. I followed the methods I saw in the forums but I get an error at the beginning. The error is "system nullreferenceexception object reference not set to an instance of an object" (first line of the try block). Also if I remove the exception handler, I get the error "Addon 90000002 failed with exception; Event type 6" in SAP B1. This is the first time I work on a system form therefore I assume that I am missing some technical requirements in the code or project settings. Also If I remove the first 2 lines of the try block code works fine.

Could you please help me with this issue

private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)

        {

            BubbleEvent = true;

            try

            {

                SAPbouiCOM.Form oForm = SBO_Application.Forms.Item(pVal.FormUID);

                SAPbouiCOM.Matrix oMatrix = oForm.Items.Item("35").Specific as SAPbouiCOM.Matrix;

              

                Application.SBO_Application.MessageBox("Hello o World");

            }

            catch (Exception e) {

                Application.SBO_Application.MessageBox(e.ToString() );

            }

        }

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi Atilla,

Can you try

                SAPbouiCOM.Form oForm = Application.SBO_Application.Forms.Item(pVal.FormUID);

                SAPbouiCOM.Matrix oMatrix = oForm.Items.Item("35").Specific as SAPbouiCOM.Matrix;

             

                Application.SBO_Application.MessageBox("Hello o World");

Regards
Edy

former_member183373
Active Participant
0 Kudos

Thank you very much Edy. I changed the code as you propose and it worked. In my code I created the "SBO_Application" as "SAPbouiCOM.Application" at the beginning and I didn't think I have to re-write it again but looks like it is necessary.

Thanks again,

Atilla

edy_simon
Active Contributor
0 Kudos

Hi Atilla,

Your problem is you have declared SBO_Application twice.

1. Once in your Application Class, which is the one you had initialized with the connection,

2. The other one is in this EventHandling class. You do not need this one since it is not initialized.

You have to always refer the SBO_Application declared in your Application class.

Regards

Edy

Answers (0)