How to update an invoice item quanity in Sage line 50 using sage data objects

I have created an invoice in sage and i want to programatically update the quantity of a item on that invocie . I have it so that i can update details such as teh date etc already but it doesnt seem to be updating the invoice items for me

any ideas ??
SageInvoice = SageWorkspace.CreateObject("InvoiceRecord") SageInvoice.Fields.Item("INVOICE_NUMBER").Value = 7
If SageInvoice.Find(True) Then
  SageInvoice.Edit()
    SageInvoice.Fields.Item("INVOICE_DATE").Value = CDate(DataSetField(OrdersDSet, i, "enddate"))
   SageInvoiceItem = SageWorkspace.CreateObject("InvoiceItem")
   ' Link Items to Header
   SageInvoiceItem = SageInvoice.Link
   SageInvoiceItem.MoveFirst()
   Do
     If SageInvoiceItem.Fields.Item("STOCK_CODE").Value ="TEST"
           SageInvoiceItem.Fields.Item("QTY_ORDER").Value = 3
           SageInvoiceItem.Fields.Item("NET_AMOUNT").Value = SageInvoiceItem.Fields.Item("UNIT_PRICE").Value * 3
 
        End if
 
   Loop Until SageInvoiceItem.MoveNext = False
 
 SageInvoice.Update
 
End if

Open in new window

LVL 1
MCLRAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Christopher KileCommented:
I don't know anything about Sage, but perhaps the InvoiceItem also has an Update method, as in the attached code snippet?
     If SageInvoiceItem.Fields.Item("STOCK_CODE").Value ="TEST"
           SageInvoiceItem.Fields.Item("QTY_ORDER").Value = 3
           SageInvoiceItem.Fields.Item("NET_AMOUNT").Value = SageInvoiceItem.Fields.Item("UNIT_PRICE").Value * 3
 
          SageInvoiceItem.Update     
     End if

Open in new window

0
MCLRAuthor Commented:
no it doesnt have one
0
Christopher KileCommented:
Are you sure the code is being executed? You might want to post to the application log (just for testing) to verify that QTY_ORDER and NET_AMOUNT are, in fact, being modified.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

MCLRAuthor Commented:
yes its definately being executed and if i run in debug mode and query the value in the  SageInvoiceItem.Fields.Item("QTY_ORDER").Value  after it runs then it is returning the updated value but it isnt updating in sage
0
MCLRAuthor Commented:
I found it i needed to add the following line

SageInvoiceItem.Write(SageInvoiceItem.RecordNumber)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Christopher KileCommented:
Congratulations :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.