cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

I can not delete item card in SAB B1 SDK

mucipilbuga
Participant
0 Kudos
252

Hi,

I want to delete item which is never used in SAP B1.

But " retval = vItem.GetByKey("test") " returns "-1" my code is below and same as in SDK help file?

Dim vItem As SAPbobsCOM.Items<br><br>        Dim retval As Long<br>        Dim ErrCode As Long<br>        Dim ErrMsg As String<br><br>        vItem = vCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)<br><br>        retval = vItem.GetByKey("test")<br><br>        Console.WriteLine(retval) ' It returns "-1" here!<br><br>        If retval <> 0 Then <br>            vCmp.GetLastError(ErrCode, ErrMsg)<br>            MsgBox("Item not found!.")<br>            MsgBox(ErrCode & " " & ErrMsg)<br><br>        Else<br>            retval = vItem.Remove<br><br>            If retval <> 0 Then<br>                vCmp.GetLastError(ErrCode, ErrMsg)<br>                MsgBox(ErrCode & " " & ErrMsg)<br><br>            Else<br>                MsgBox("Başarı ile silindi")<br><br>            End If<br><br><br>        End If

Regards,

Mucip:)

Accepted Solutions (0)

Answers (1)

Answers (1)

mucipilbuga
Participant
0 Kudos

Dear dell.stinnett-christy,
OK. Thanks.

By the way I found the solution. I don't know why Retval is sometimes Boolean and sometimes Long.

When I change it long to Boolean than it started to work.

Regards,

Mucip:)