0

I am creating an addon in SAP Business One and I need to fill a matrix with data as soon as the form loads.

I have the following code:

private void Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
{
    BubbleEvent = true;

    try
    {
        (pVal.FormTypeEx == "UDO_FT_CASHBOOK" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.BeforeAction == false)
            {
                SAPbobsCOM.Recordset rs = (SAPbobsCOM.Recordset)SboConnection.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                ...more code...
                
                oform = SboConnection.SboApplication.Forms.ActiveForm;

                // Get matrix
                oItem = oform.Items.Item("0_U_G"); <----------------error thrown: 
                oMatrix = (SAPbouiCOM.Matrix)(oItem.Specific);

Error gets thrown at the above line because that item element does not exist yet.

How do I get to fill matrix data as soon as the form has loaded?

Kinyanjui Kamau
  • 1,890
  • 10
  • 55
  • 95

1 Answers1

0

when i encountered this problem, using:

SAPbouiCOM.BoEventTypes.et_FORM_VISIBLE

instead of

SAPbouiCOM.BoEventTypes.et_FORM_LOAD

corrected the issue.

Praxiom
  • 578
  • 1
  • 8
  • 21