简体   繁体   中英

How do I catch the item event in SAP B1 after all elements on a form have loaded?

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?

when i encountered this problem, using:

SAPbouiCOM.BoEventTypes.et_FORM_VISIBLE

instead of

SAPbouiCOM.BoEventTypes.et_FORM_LOAD

corrected the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM