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
177

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?

Accepted Solutions (1)

Accepted Solutions (1)

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

Answers (3)

Answers (3)

ens_
Active Participant
0 Kudos

another thing, when i have a customer code in the CFL edit text and try to update, i receive the following error.

and the update does not occur

Former Member
0 Kudos

Hi Varnavas,

First of all , a silly question, BP Code 140313 exist in the database?

Secondly, -Linked Value Not Exist- error may caused for the following reasons:

  • You have assign string and not an integer as ObjectKey for the Link Button
  • You are providing a null value as ObjectKey (In this case you have to assign to the EditText at the top of the form a UserDataSource)

In any case, i want to ask you; the link button that is not working is located at the EditText or at the Grid? Because in case that you have placed it on the grid, make sure that the link button is anchored with BP Code and not CardName. You are not having a CardCode column. In case that you have a Link Button that is connected with the Editext (at the top of the form) even with the EditText contains data, is one other problem.

Kind Regards

Evangelos D. Plagianos

ens_
Active Participant
0 Kudos

Dear Vaggelis,

Yes, the BP selection filters the results on the grid, so it does exist no worries about silly questions. Many times we all face small simple problems like that one!

I use Int.Parse and i parse from string to Int. The linked button works fine.

The use of Update Button is completely irrelevant with the EditText field with the CFL.

CFL EditText field works as a FILTER for the query that will be run on the grid.

when i issue a change on the grid enabled fields, the "1" button changes to Update.

When i click update the event triggered is correct i just get an extra error below which i show on the first screenshot.

The second screenshot below pops that error when i have a value in the EditText on the top and i click update

former_member233854
Active Contributor
0 Kudos

Hi Varnavas, I believe it is the same as mentioned, did you remove the ObjectType property of the form? It must be blank in this case.

Do you have any field linked to the OCRD.GroupCode?

ens_
Active Participant
0 Kudos

Hi Danilo,

Yes I removed the ObjectType linkage between the form and '2' (BPs) and created an event that would handle the selection of the text and parse it to the TextField as Edy suggested! It works okay now.

former_member183373
Active Participant
0 Kudos

Hello Varnavas,

Have you checked the below discussion? It seems another member managed to resolve the same issue you are having.

How to add a user defined field to Business Par... | SCN

Kind Regards,

Atilla

ens_
Active Participant
0 Kudos

It appears to be irrelevant with the current subject. No other form is active during the editing of the SCs. Before I add the CFL feature, i wouldn't get any errors. I would like to keep the CFL feature though. By the way, the code executes fine most of the times while sometimes it will not do the update of the SCs. Error always appears.

former_member233854
Active Contributor
0 Kudos

After you run oSCs.GetByKey(int.Parse(CallID)); try to get the oSCs.CustomerCode value to see what you have there.

Do you have any UDO linked to your form?"

ens_
Active Participant
0 Kudos

I am not at the office right now, i will check the value when Im back and reply again. No UDO linked to the form. Its just a query grid that will also capture SC id and change some UDFs of the SC Form (system form)

ens_
Active Participant
0 Kudos

As i suspected, the result is the respective Service Call Customer Code on each step. It is irrelevant with the customer i have in my CFL list.