cancel
Showing results for 
Search instead for 
Did you mean: 

Error when trying to delete data from udo

Former Member
0 Kudos

Hello Experts ,

I want to delete a specific entry from a udo and the error is the folowing : "Error2Argument 1: cannot convert from 'SAPbobsCOM.GeneralData' to 'SAPbobsCOM.GeneralDataParams" and "Error1The best overloaded method match for 'SAPbobsCOM.IGeneralService.Delete(SAPbobsCOM.GeneralDataParams)' has some invalid arguments"

The code is the folowing in c# :

SAPbobsCOM.GeneralService oGeneralService1 = null;

SAPbobsCOM.GeneralData oGeneralData1 = null;

SAPbobsCOM.GeneralDataParams oGeneralParams1;

SAPbobsCOM.CompanyService sCmp1;

sCmp1 = oCompany.GetCompanyService();

oGeneralService1 = sCmp1.GetGeneralService("Seg");

oGeneralData1 = oGeneralService1.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

SAPbobsCOM.GeneralData oSon1;

SAPbobsCOM.GeneralDataCollection oSons1;

oGeneralParams1 = (SAPbobsCOM.GeneralDataParams)oGeneralService1.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);

oGeneralData1.GetProperty("" + CodeOfTicket + "");

oGeneralService1.Delete(oGeneralData1);

The error is in the last line

Please advice

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

Hi Ifigenia,

When you want delete a register from an UDO, you need provide GeneralDataParams in the delete method.

Try something like this:

            SAPbobsCOM.GeneralService oGeneralService1 = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams1;
            SAPbobsCOM.CompanyService sCmp1;


            try
            {
                sCmp1 = oCompany.GetCompanyService();
                oGeneralService1 = sCmp1.GetGeneralService("Seg");
                oGeneralParams1 = oGeneralService1.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                oGeneralParams1.SetProperty("Code", CodeOfTicket);
                oGeneralService1.Delete(oGeneralParams1);
            }
            catch (Exception ex)
            {
                //Do something
            }

If your UDO is MasterData you need provide "Code" as key in SetProperty method, if is a Document, you need provide "DocEntry" as key in SetProperty method.

Hope it helps.

Kind Regards,

Diego Lother

Answers (0)