11-18-2016 3:44 PM - edited 01-21-2024 10:06 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.