cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot update user define field

Former Member
0 Kudos

Hi,

I'm having problem update my user defined field which I added via SAPB1 under the marketing document. This is my code in VB when I try to update the field.

Also to note, I got no error when I call the update method.

Set oDoc = oCompany.GetBusinessObject(oStockTransfer)

oDoc.GetByKey (8)

oDoc.Lines.SetCurrentLine (0)

oDoc.Lines.UserFields("U_OB_STSta").Value = "A"

lngRetCode = oDoc.Update

If lngRetCode <> 0 Then

End If

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try

oDoc.Lines.UserFields.Fields.Item("U_OB_STSta").Value = "A"

HTH

Juha

Former Member
0 Kudos

I tried and still cannot.

Former Member
0 Kudos

What is the error?

Former Member
0 Kudos

No error. the return was a 0.

Former Member
0 Kudos

Hi Ivan,

Are you sure you are looking at the correct document? The GetByKey method uses DocEntry and not DocNum. Your DocNum could be 8 and the DocEntry something else. Which means you won't get the correct document.

Maybe also do a check if the document is retrieved.

If oDoc.GetByKey (8) then
...

Adele

Former Member
0 Kudos

At time point of time, my DocEntry and DocNum is the same. Anyway i queried the entire table and no change.

Former Member
0 Kudos

Hi Ivan,

I have tested successfully. This is my code. I don't know why your's aren't working.

  Dim oDoc As SAPbobsCOM.Documents
  oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)
  oDoc.GetByKey(147)
  oDoc.UserFields.Fields.Item("U_Field").Value = "XX"
  If oDoc.Update <> 0 Then
      Dim i As Long
      Dim s As String
      oCompany.GetLastError(i, s)
      oApplication.MessageBox("Error: " & s)
  Else
      oApplication.MessageBox("Updated")
  End If

Adele.

Answers (0)