Search the GP Tables
Search by TABLE NAME
Search by FIELD NAME
These are our SOP scripts. All of our scripts for Dynamics GP can be found here
DynDeveloper.com

DynDeveloper.com

Table Edits Forum Articles
Table Edits 0 Table Edits 0 Table Edits 0
Sign Up Now!Log In
AshleyRP 7/30/2008 12:24:50 PM

Multiple Line Items with VB Loop in eConnect

I am having some problems getting this code to work correctly. I loop through rows in a data set where each row represents one line item for an invoice. I would like to preserve the data in the previous row when it goes on to the next. What happens now is when the code loops to the second row, the first is being overwritten with whatever is in the second. For example, if the first row contains item number 123, it initially goes in as item 123. If the second row contains item number 234, I then have 2 rows of data. Both containing item 234. If a third item contains item 345, I will then have 3 rows of data containing item 345. This data is then written into XML once the sales header is created, giving me incorrect line items in my GP invoice. I'm not sure if this is a VB or an eConnect issue, but it is driving me mad! I have attached my code below. If more is needed, just let me know, and PLEASE help. Thanks in advance!

For Each Module1.dr In dt.Rows

r = r + 1

With salesLine

Quantity = ds.Tables.Item(0).Rows(r).Item(12).ToString

ItemNo = ds.Tables.Item(0).Rows(r).Item(13).ToString

CustomerName = ds.Tables(0).Rows(r).Item(0).ToString

Phone = ds.Tables(0).Rows(r).Item(10).ToString

Shipping = ds.Tables(0).Rows(r).Item(8).ToString

.DEFPRICING = 1

.CUSTNMBR = "294496"

.SOPNUMBE = SopNumber

.AutoAssignBin = 0

.DOCDATE = Today

.SOPTYPE = 3

.DOCID = "CB"

.QUANTITY = Quantity

.ITEMNMBR = ItemNo

.LOCNCODE = "PORT ALLEN"

End With

ReDim Preserve LineItems(0 To i)

LineItems(i) = salesLine

i = i + 1

Next

Version: Unknown or N/A
Section: eConnect








Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables
site