2can2 wrote:Hi, Is there any way that we can import NEW SO lines to an Existing SO at a specific position? If I have a SO with 5 lines I would like to insert a comment line after SO Line1 and then add a NEW SO line after this Comment line - now this would be line 3? LineNo seems to be ignored. The client doesn't use stock control all items are Non physical. Thanks.
2can2 wrote:It is using an XML file. I did try with the LineNo syntax but obviously it had no effect. Thanks in advance.
salesOrder.Deserialise(xmlText)
' ***********************************************************************************************************************************
' Set the ItemNo - as the Deserialise method does not attempt to do this, we need to read in the XML string to a new XML.SalesOrder
' then parse that and match against the salesOrder object the line and set the ItemNo
' Note that we may be importing a complete order, or a partial update - so we are not guaranteed there will be a 1:1 match in the lines
' Also note comment lines may exist
Dim XMLSalesOrder As JiwaSales.SalesOrder.XML.SalesOrder = Nothing
Dim xmlSerializer As New System.Xml.Serialization.XmlSerializer(GetType(JiwaSales.SalesOrder.XML.SalesOrder))
Using stringReader As New System.IO.StringReader(xmlText)
XMLSalesOrder = xmlSerializer.Deserialize(stringReader)
stringReader.Close()
End Using
If XMLSalesOrder IsNot Nothing Then
For Each XMLSalesOrderLine As JiwaSales.SalesOrder.XML.Line In XMLSalesOrder.Lines
If XMLSalesOrderLine.ItemNoSpecified AndAlso XMLSalesOrderLine.ItemNo > 0 Then
For Each salesOrderLine As JiwaSales.SalesOrder.SalesOrderLine In salesOrder.SalesOrderLines
If ((XMLSalesOrderLine.CommentLine AndAlso salesOrderLine.CommentLine AndAlso XMLSalesOrderLine.CommentText = salesOrderLine.CommentText) _
OrElse _
(XMLSalesOrderLine.CommentLine = False AndAlso salesOrderLine.CommentLine = False AndAlso XMLSalesOrderLine.PartNo.ToLower.Trim = salesOrderLine.PartNo.ToLower.Trim)) Then
salesOrderLine.ItemNo = XMLSalesOrderLine.ItemNo
Exit For
End If
Next
End If
Next
End If
' ***********************************************************************************************************************************
salesOrder.Save()
Return to Technical and or Programming
Users browsing this forum: No registered users and 20 guests