on 02-05-2014 9:18 AM
hello pals,
Please can someone show me how to update OINV and INV1 respectively through code.am developing an Add-on which will update this two tables and the OINV table get updated correctly but the INV1 tables does not but rather insert new records.
Hi Annie,
SInce you are not familiar with sdk yet,
i suggest you make yourself comfortable first by removing the loop and try to hardcode everything.
this code is to update the first line
oInvoice.Lines.SetCurrentLine(0)
oInvoice.Lines.ItemCode = 'AnyItemCodeHere'
oInvoice.Update
check your invoice....
if your invoice has 3 lines. Use this to update the last line.
oInvoice.Lines.SetCurrentLine(2)
oInvoice.Lines.ItemCode = 'AnyItemCodeHere'
oInvoice.Update
check your invoice....
Use this to add a new line
oInvoice.Lines.Add
oInvoice.Lines.ItemCode = 'AnyItemCodeHere'
oInvoice.Lines.Quantity =1
oInvoice.Update
check your invoice....
Regards,
edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Annie,
To update a specific line of document, you need to query the document first and look for the VisOrder field.
The use this method to call the line you need to update, passing the VisOrder you have got from the query.
oDocs.Lines.SetCurrentLine(iVisOrder);
..Update all your data here.
Then execute the update function,
oDocs.Update();
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Edy,
Have done as you said but is still inserting instead of updating.below is the code for doing the update.
If oInvoice.GetByKey(lngDocEntry) = True Then
oInvoice.CardCode = strCardCode
oInvoice.DocTotal = DocTotalvalue
For Each classItems As DraftClass In itemsData
oInvoice.Lines.ItemCode = classItems.itemCode
oInvoice.Lines.Price = classItems.PriceBefDi
oInvoice.Lines.PriceAfterVAT = classItems.PriceAfVat
oInvoice.Lines.LineTotal = classItems.LineTotal
oInvoice.Lines.GrossBuyPrice = classItems.GrossProfit
oInvoice.Lines.SetCurrentLine(classItems.VisOrder)
oInvoice.Lines.Add()
Next
lRetCode = oInvoice.Update()
If lRetCode <> 0 Then
oCompany.GetLastError(lErrcode, sErrMsg)
SBO_Application.MessageBox(lErrcode & " " & sErrMsg, 1, "", "", "")
Else
RetvalInoviceId = oCompany.GetNewObjectKey()
End If
End If
For Each classItems As DraftClass In itemsData
oInvoice.Lines.ItemCode = classItems.itemCode
oInvoice.Lines.Price = classItems.PriceBefDi
oInvoice.Lines.PriceAfterVAT = classItems.PriceAfVat
oInvoice.Lines.LineTotal = classItems.LineTotal
oInvoice.Lines.GrossBuyPrice = classItems.GrossProfit
oInvoice.Lines.Add()
oInvoice.Lines.SetCurrentLine(classItems.VisOrder)
Next
lRetCode = oInvoice.Update()
Hi Annie,
For Each classItems As DraftClass In itemsData
oInvoice.Lines.SetCurrentLine(classItems.VisOrder) '<-- Before update, set the line first
oInvoice.Lines.ItemCode = classItems.itemCode
oInvoice.Lines.Price = classItems.PriceBefDi
oInvoice.Lines.PriceAfterVAT = classItems.PriceAfVat
oInvoice.Lines.LineTotal = classItems.LineTotal
oInvoice.Lines.GrossBuyPrice = classItems.GrossProfit
'oInvoice.Lines.Add() <--- updating line, no need to add, unless you want to add a new line
Next
lRetCode = oInvoice.Update()
Regards
Edy
hi edy,
oInvoice.Lines.SetCurrentLine(classItems.VisOrder)
oInvoice.Lines.ItemCode = classItems.itemCode
oInvoice.Lines.Price = classItems.PriceBefDi
oInvoice.Lines.PriceAfterVAT = classItems.PriceAfVat
oInvoice.Lines.LineTotal = classItems.LineTotal
oInvoice.Lines.GrossBuyPrice = classItems.GrossProfit
with the above code the items does not get updated at all when i move the
oInvoice.Lines.SetCurrentLine(classItems.VisOrder) at bottom it updates but leaves the last record out.
User | Count |
---|---|
91 | |
7 | |
7 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.