Skip to Content
0

Error when trying to delete data from udo

Nov 18, 2016 at 03:44 PM

80

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
DIEGO LOTHER Nov 18, 2016 at 04:23 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded