Skip to Content
avatar image
Former Member

Error when trying to delete data from udo

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 18, 2016 at 04:23 PM

    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

    Add comment
    10|10000 characters needed characters exceeded