nooruddinazhar
IS-IT--Management
Hi,
In the samples provided in the eConnect Documentation, everywhere it's for single record i.e. for one single node for any transaction type. If I want to upload more than one transaction - multiple transactions - my code doesn't work. Always my only single record is getting inserted into Dynamics GP. I want to insert more than one, where am I missing?
In my below code at : eConnect.RMTransactionType(0) = MyType(0)
I want to send two records & similarly in a loop multiple records basically the taRMtransaction object should be made an array & passed to the RMTransactionType(0) object. How to be done? Pls. help.
Public Shared Sub SerializeReceivablesObject(ByVal filename As String)
Try
Dim MyType(1) As RMTransactionType
Dim MyTransactions(1) As taRMTransaction
Dim LineItems(1) As taRMTransaction
'Populate the XML node object
LineItems(0) = New taRMTransaction
With LineItems(0)
.BACHNUMB = "MYBATCH"
.BatchCHEKBKID = "UPTOWN TRUST"
.SLSAMNT = "100"
.DOCAMNT = "100"
.CASHAMNT = 0
.CUSTNMBR = "AARONFIT0001"
.DOCDATE = DateTime.Parse("01/06/2012")
.DOCNUMBR = "INV17062012-001"
.SALSTERR = "TERRITORY 1"
.SLPRSNID = "PAUL W."
.RMDTYPAL = "1"
End With
MyTransactions(0) = LineItems(0)
LineItems(1) = New taRMTransaction
With LineItems(1)
.BACHNUMB = "MYBATCH"
.BatchCHEKBKID = "UPTOWN TRUST"
.SLSAMNT = "200"
.DOCAMNT = "200"
.CASHAMNT = 0
.CUSTNMBR = "ADAMPARK0001"
.DOCDATE = DateTime.Parse("01/06/2012")
.DOCNUMBR = "INV17062012-002"
.SALSTERR = "TERRITORY 2"
.SLPRSNID = "SANDRA M."
.RMDTYPAL = "1"
End With
MyTransactions(1) = LineItems(1)
Dim eConnect As New eConnectType
Dim MyeConnect(1) As eConnectType
Dim MyTransaction As New taRMTransaction
ReDim Preserve eConnect.RMTransactionType(0)
Dim MyTransArray As New List(Of taRMTransaction)()
MyTransArray.Add(MyTransactions(0))
MyTransArray.Add(MyTransactions(1))
MyType(0) = New RMTransactionType
MyType(1) = New RMTransactionType
MyType(0).taRMTransaction = MyTransArray.Item(0)
MyType(1).taRMTransaction = MyTransArray.Item(1)
eConnect.RMTransactionType(0) = MyType(0)
'Create a file and stream to use to serialize the XML document to a file
Dim fs As New FileStream(filename, FileMode.Create)
Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
'Serialize the XML document to the file
Dim serializer As New XmlSerializer(GetType(eConnectType))
serializer.Serialize(writer, eConnect)
writer.Close()
Catch ex As ApplicationException
Console.Write(ex.ToString)
End Try
End Sub
In the samples provided in the eConnect Documentation, everywhere it's for single record i.e. for one single node for any transaction type. If I want to upload more than one transaction - multiple transactions - my code doesn't work. Always my only single record is getting inserted into Dynamics GP. I want to insert more than one, where am I missing?
In my below code at : eConnect.RMTransactionType(0) = MyType(0)
I want to send two records & similarly in a loop multiple records basically the taRMtransaction object should be made an array & passed to the RMTransactionType(0) object. How to be done? Pls. help.
Public Shared Sub SerializeReceivablesObject(ByVal filename As String)
Try
Dim MyType(1) As RMTransactionType
Dim MyTransactions(1) As taRMTransaction
Dim LineItems(1) As taRMTransaction
'Populate the XML node object
LineItems(0) = New taRMTransaction
With LineItems(0)
.BACHNUMB = "MYBATCH"
.BatchCHEKBKID = "UPTOWN TRUST"
.SLSAMNT = "100"
.DOCAMNT = "100"
.CASHAMNT = 0
.CUSTNMBR = "AARONFIT0001"
.DOCDATE = DateTime.Parse("01/06/2012")
.DOCNUMBR = "INV17062012-001"
.SALSTERR = "TERRITORY 1"
.SLPRSNID = "PAUL W."
.RMDTYPAL = "1"
End With
MyTransactions(0) = LineItems(0)
LineItems(1) = New taRMTransaction
With LineItems(1)
.BACHNUMB = "MYBATCH"
.BatchCHEKBKID = "UPTOWN TRUST"
.SLSAMNT = "200"
.DOCAMNT = "200"
.CASHAMNT = 0
.CUSTNMBR = "ADAMPARK0001"
.DOCDATE = DateTime.Parse("01/06/2012")
.DOCNUMBR = "INV17062012-002"
.SALSTERR = "TERRITORY 2"
.SLPRSNID = "SANDRA M."
.RMDTYPAL = "1"
End With
MyTransactions(1) = LineItems(1)
Dim eConnect As New eConnectType
Dim MyeConnect(1) As eConnectType
Dim MyTransaction As New taRMTransaction
ReDim Preserve eConnect.RMTransactionType(0)
Dim MyTransArray As New List(Of taRMTransaction)()
MyTransArray.Add(MyTransactions(0))
MyTransArray.Add(MyTransactions(1))
MyType(0) = New RMTransactionType
MyType(1) = New RMTransactionType
MyType(0).taRMTransaction = MyTransArray.Item(0)
MyType(1).taRMTransaction = MyTransArray.Item(1)
eConnect.RMTransactionType(0) = MyType(0)
'Create a file and stream to use to serialize the XML document to a file
Dim fs As New FileStream(filename, FileMode.Create)
Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
'Serialize the XML document to the file
Dim serializer As New XmlSerializer(GetType(eConnectType))
serializer.Serialize(writer, eConnect)
writer.Close()
Catch ex As ApplicationException
Console.Write(ex.ToString)
End Try
End Sub