logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Ken Morey  
#1 Posted : Friday, August 21, 2020 4:02:47 PM(UTC)
Ken Morey

Rank: Newbie

Groups: Registered
Joined: 3/6/2018(UTC)
Posts: 7
United States
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
aarony  
#2 Posted : Friday, August 21, 2020 5:45:37 PM(UTC)
aarony

Rank: Administration

Groups: Administrators, Moderator, Registered
Joined: 2/28/2018(UTC)
Posts: 50
Location: Red Wing, MN

Was thanked: 3 time(s) in 3 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.
Users browsing this topic
Guest
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.