Rank: Newbie
Groups: Registered
Joined: 3/6/2018(UTC) Posts: 7 Location: Peoria, IL
|
To update I thought that I would simply get the sales item for a transaction and then make the addreplace followed by a SaveTransaction. To get the GetSalesItemLineObject I need a key parameter of type string. What is the key? My code is contained below. I also wonder if I missed something?
Public Sub Update(ByVal sotid As Integer) API.SalesOrderPresenter.LoadExistingTransaction(2147459962, True) API.SalesOrderPresenter.Company = 2147470000 API.SalesOrderPresenter.TransactionDate = DateTime.Today API.SalesOrderPresenter.EarliestDate = DateTime.Today API.SalesOrderPresenter.ExistingStatus = SalesOrderStatus.Open API.SalesOrderPresenter.Customer = 2147469999 Dim subline As SalesItemLineObject subline = API.SalesOrderPresenter.GetSalesItemLineObject(Key) subline.LineValues.AddReplace(InputFieldTypes.QuantityOrdered, 100) subline.LineValues.AddReplace(InputFieldTypes.SalesPrice, 10.0) API.SalesOrderPresenter.UpdateLineItemValuesForAllLines() API.SalesOrderPresenter.SaveTransaction(False)
End Sub
|
|
|
|
Rank: Administration
Groups: Administrators, Moderator, Registered Joined: 2/28/2018(UTC) Posts: 53 Location: Red Wing, MN
Was thanked: 4 time(s) in 4 post(s)
|
The best way to approach this would be to enumerate all the lines on the order and when you've found the one you want to edit, modify it. For example: Code:Public Sub Update(ByVal sotid As Integer)
API.SalesOrderPresenter.LoadExistingTransaction(2147459962, True)
API.SalesOrderPresenter.Company = 2147470000
API.SalesOrderPresenter.TransactionDate = DateTime.Today
API.SalesOrderPresenter.EarliestDate = DateTime.Today
API.SalesOrderPresenter.ExistingStatus = SalesOrderStatus.Open ' This won't do anything and should be read-only.
API.SalesOrderPresenter.Customer = 2147469999
' Enumerate all the sales order lines
For Each key In API.SalesOrderPresenter.TransactionLinesKeys
' get the line object
Dim line = API.SalesOrderPresenter.GetTransactionLineObject(key)
' If it's a Sales Item Line, do something with it...
If TypeOf line Is SalesItemLineObject Then
Dim itemLine = TryCast(line, SalesItemLineObject)
' See if the sales item is what we're looking for
If itemLine.SalesItem = 2147469986 Then
itemLine.LineValues.AddReplace(InputFieldTypes.QuantityOrdered, 100)
itemLine.LineValues.AddReplace(InputFieldTypes.SalesPrice, 10.0)
End If
ElseIf TypeOf line Is AccountLineObject Then
' Do something with Account line items
Dim accountLine = TryCast(line, AccountLineObject)
End If
Next
API.SalesOrderPresenter.UpdateLineItemValuesForAllLines()
API.SalesOrderPresenter.SaveTransaction(False)
End Sub
Keep in mind that each time you edit a Sales Order you're essentially deleting the old one and create a new one, so the ID will change. Regards, - Aaron.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Red Wing Software Developer Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close