cancel
Showing results for 
Search instead for 
Did you mean: 

SBO Addon throws a missing BP Code during "1" click (update)

ens_
Active Participant
0 Kudos
194

Dear Community,

I have been meddling with a weird error on one of my personal addons. The problem is, when I hit update button i get the following error

Below you can see the code of the Update Button;

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

        {

            BubbleEvent = true;

            if (Application.SBO_Application.Forms.ActiveForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE)

            {

                int cnt = Grid4.Rows.Count;

                int rowIndex, ok;

                string CallID;

                int count = Grid4.DataTable.Rows.Count - 1;

                ProgressBar0 = Application.SBO_Application.StatusBar.CreateProgressBar("Checking Completed Service Calls", cnt - 1, false);

                ProgressBar0.Value = 0;

                for (int i = 0; i < cnt; i++)

                {

                    try

                    {

                        showRow = int.Parse(Grid4.DataTable.Columns.Item("CallID").Cells.Item(i).Value.ToString());

                        ProgressBar0.Value = i;

                        ProgressBar0.Text = i + "/" + cnt + " - " + showRow;

                    }

                    catch { }

                    rowIndex = Grid4.GetDataTableRowIndex(i);

                    if (rowIndex != -1)

                    {

                        try

                        {

                            CallID = Grid4.DataTable.GetValue("CallID", rowIndex).ToString();

                            oSCs = ((SAPbobsCOM.ServiceCalls)(Globals.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oServiceCalls)));

                            oSCs.GetByKey(int.Parse(CallID));

                            oSCs.UserFields.Fields.Item("U_Completed").Value = Grid4.DataTable.GetValue("Completed", rowIndex).ToString();

                           

                            oSCs.UserFields.Fields.Item("U_SalesOrder").Value = Grid4.DataTable.GetValue("Sales Order", rowIndex).ToString();

                            ok = oSCs.Update();

                            if (ok != 0)

                            {

                                Application.SBO_Application.MessageBox(Globals.oCompany.GetLastErrorDescription().ToString(), 1, "Ok", "", "");

                            }

                        }

                        catch { ProgressBar0.Stop(); }

                    }

                }

                ProgressBar0.Stop();

            }

       }

What i noticed though, is that this is caused whenever i use CFL (Choose From List). Here is the CFL Feature i use

The Properties of the EditText Field are:

The CFL datasource properties are:

Any Ideas why this happens?

View Entire Topic
edy_simon
Active Contributor
0 Kudos

Hi Varnavas,

Did you assign your form object type as '2'?

Can you post the screen shot of your form properties

Regards

Edy

ens_
Active Participant
0 Kudos

Hi Eddy, Yes if i do not assign it the CFL does not function. Also, Its 2 separate things (the Update and the choice of having to view a specific BP)

edy_simon
Active Contributor
0 Kudos

Hi Varnavas,

You must not set the form type to a system object,

The system will think that you are trying to update/Add this object.

As for the CFL you have to handle the OnAfterChooseFromList event.

Regards

Edy

ens_
Active Participant
0 Kudos

Thanks Eddy.

Any example on how to handle the CFLSelectAfter Event and grab CardCode and set it to the EditText Field?

edy_simon
Active Contributor
0 Kudos

Hi Varnavas,

If you are not using B1Studio for Visual Studio / SBO 9+

follow the sample in your SDK help

C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\CSharp\17.ChooseFromList

If you are using SBO9+ and using the new Framework,

Follow the above sample, but instead of these lines :


SAPbouiCOM.IChooseFromListEvent oCFLEvento = null;

oCFLEvento = ( ( SAPbouiCOM.IChooseFromListEvent )( pVal ) );

Use


SAPbouiCOM.ISBOChooseFromListEventArg oCFLEvento = SAPbouiCOM.ISBOChooseFromListEventArg)pVal;

Regards

Edy

ens_
Active Participant
0 Kudos

Done. Thank you very much it works perfectly fine now