Writing /C comment to sales order

Is it possible to write a "/C" comment line item to a sales order using BOI? If so how? The VB code I am currently using is more or less this modulo checking response codes and logging:

Dim oSOrder As Object

Dim sItemCode As String

Dim sQuantityOrdered As String

Dim sUnitPrice As String

Dim sCommentText As String

'Fill in code to connect to sage, initialize oSOrder, and pull in values for fields here

'...

oSOrder.oLines.nAddLine()

oSOrder.oLines.nSetValue("ItemCode$",sItemCode)

oSOrder.oLines.nSetValue("QuantityOrdered",CInt(sQuantityOrdered))

If Not (sUnitPrice = "") Then

    oSOrder.oLines.nSetValue("UnitPrice",Double.Parse(UnitPrice))

End If

If Not (sCommentText = "") Then

    oSOrder.oLines.nSetValue("CommentText$",sCommentText)

End If

oSOrder.oLines.nWrite()

(Here fields are dimed as strings because of how data is retrieved from external sources) 

The above works fine with a regular item

e.g. sItemCode = "SKU" , sQuantityOrdered = "1", sUnitPrice = "10", sCommentText = "This is a comment"

but when I try

sItemCode = "/C", sQuantityOrdered = "0", sUnitPrice = "", sCommentText = "This is a comment"

I get an error at  the oSOrder.oLines.nWrite() line :"The 023530300000100000000000001 is invalid."  I believe that this number is something like [OrderNumber][LineKey][LineSeqNo], thus all it is telling me is that the line I'm trying to write is invalid. So... How do I make it valid? Incidentally I've also tried writing a UnitPrice and not writing a QuantityOrdered to the line, but I still get the same error.

Thanks

  • 0

    Sometimes it helps to try it in the User Interface to see what the screens are doing.  Quantity Ordered and Unit Price are disabled for comment lines.  You don't want to set those fields at all.

  • 0 in reply to hyanaga

    Thanks for the response. I've tried the User Interface there isn't anything there that jumps out at me that I'm missing. Do you have any specifics for which fields might need writing. As I mentioned above, I tried not writing a QuantityOrdered and UnitPrice to the line and I get the same error, that is only writing "/C" as the ItemCode and the comment in the CommentText Field. Incidently, when I dump the data from the SO_SalesOrderDetail table I see  that /C comments are still written with 0 ItemQuantity, even though this field is not writable in UI.

  • 0

    Try using just the following hard-coded lines to test the result of the write. 


    oSOrder.oLines.nAddLine()
    oSOrder.oLines.nSetValue("ItemCode$","/C")
    oSOrder.oLines.nSetValue("CommentText$","This is a comment")
    oSOrder.oLines.nWrite()


    You can also try checking the return value and the oSOrder.oLines.sLastErrorMsg property after the nSetValue on the ItemCode field.

  • 0 in reply to David Speck

    I found that I also had to set the ItemType in order to add a line comment

    oSOrder.oLines.nAddLine()
    oSOrder.oLines.nSetValue("ItemType$", "4")
    oSOrder.oLines.nSetValue("ItemCode$","/C")

    oSOrder.oLines.nSetValue("CommentText$","This is a comment")
    oSOrder.oLines.nWrite()