eConnect GetNextDocNumbers Class vb.net example

Use left and right arrow keys to scroll horizontally

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Public Class econnectApplication
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim sConnectionString As String = "data source=[SQLSERVER];initial catalog=PDT;integrated security=SSPI; persist security info=False;packet size=4096"
        Dim NextNumberObject As New GetNextDocNumbers

        'Journal  # 
        MsgBox(NextNumberObject.GetNextGLJournalEntryNumber(IncrementDecrement.Increment, sConnectionString))

        'Inventory Document # IVDocType.IVAdjustment
        MsgBox(NextNumberObject.GetNextIVNumber(IncrementDecrement.Increment, IVDocType.IVAdjustment, sConnectionString))

        'Inventory Document # IVDocType.IVTransfer
        MsgBox(NextNumberObject.GetNextIVNumber(IncrementDecrement.Increment, IVDocType.IVTransfer, sConnectionString))

        'Inventory Document # IVDocType.IVVariance
        MsgBox(NextNumberObject.GetNextIVNumber(IncrementDecrement.Increment, IVDocType.IVVariance, sConnectionString))

        'Purchase Order # 
        MsgBox(NextNumberObject.GetNextPONumber(IncrementDecrement.Increment, sConnectionString))

        'PO Receipt #
        MsgBox(NextNumberObject.GetNextPOPReceiptNumber(IncrementDecrement.Increment, sConnectionString))

        'Receivable # - RMPaymentType.RMCreditMemo
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMCreditMemo, sConnectionString))

        'Receivable # - RMPaymentType.RMDebitMemos
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMDebitMemos, sConnectionString))

        'Receivable # - RMPaymentType.RMFinanceCharges
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMFinanceCharges, sConnectionString))

        'Receivable # - RMPaymentType.RMInvoices
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMInvoices, sConnectionString))

        'Receivable # - RMPaymentType.RMPayments
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMPayments, sConnectionString))

        'Receivable # - RMPaymentType.RMReturn
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMReturn, sConnectionString))

        'Receivable # - RMPaymentType.RMScheduledPayments
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMScheduledPayments, sConnectionString))

        'Receivable # - RMPaymentType.RMServiceRepairs
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMServiceRepairs, sConnectionString))

        'Receivable # - RMPaymentType.RMWarranty
        MsgBox(NextNumberObject.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMWarranty, sConnectionString))

        'SOP # -SopType.SOPInvoice
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPBackOrder, sConnectionString))

        'SOP # - SopType.SOPBackOrder
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPInvoice, sConnectionString))

        'SOP # - SopType.SOPOrder
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPOrder, sConnectionString))

        'SOP # - SopType.SOPQuote
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPQuote, sConnectionString))

        'SOP # - SopType.SOPReturn
        MsgBox(NextNumberObject.GetNextSOPNumber(IncrementDecrement.Increment, "DOCID", SopType.SOPReturn, sConnectionString))

        'Payable Voucher # 
        MsgBox(NextNumberObject.GetPMNextVoucherNumber(IncrementDecrement.Increment, sConnectionString))

        NextNumberObject.Dispose()

    End Sub
End Class

Summary Reference:

GetNextDocNumbers Class

The GetNextDocNumbers class allows you to retrieve the next valid document   number for several Microsoft Dynamics GP document types.

Methods
Name Return Value Description
Dispose void Releases the   resources of the GetNextDocNumbers object.
GetNextGLJournalEntryNumber string Retrieves the next   general ledger journal entry document number.
GetNextIVNumber string Retrieves the next   document number for a specified type of inventory document.
GetNextPONumber string Retrieves the next   purchase order number.
GetNextPOPReceiptNumber string Retrieves the next   purchase order receipt document number.
GetNextRMNumber string Retrieves the next   document number for a specified type of receivable document.
GetNextSOPNumber string Retrieves the next   document number for a specified type of sales order document.
GetPMNextVoucherNumber string Retrieves the next   payables management document number.
RollBackDocumentList   Method void Returns one or more   unused document numbers.
SortAndRollBackDocumentList   Method void Sorts and rolls back   a list of document numbers.

 

 

Dynamics GP eConnect – Create Customer – Parent ID – VB.net example

In this VB.net example, eConnect API  is used to create a customer  record as parent customer.  The script will also add two addresses and an internet information record as presented in previous articles.

parent record

VB.Net Scripts consists of two procedures, and can be initiated by calling the eConnectSend() procedure. Update the SQL Server and company database at connection string.

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Public Class econnectApplication
    Public Sub eConnectSend()
        'Serialized XML File         
        Dim xmldocument As String
        'Connection String         
        Dim sConnectionString As String
        'Result         
        Dim xmlobject As String
        Using eConCall As New eConnectMethods
            Try
                SerializeObject("xmlfile.xml ")
                Dim xmldoc As New Xml.XmlDocument
                xmldoc.Load("xmlfile.xml")
                xmldocument = xmldoc.OuterXml
                sConnectionString = "data source=[sqlserver];initial catalog=[companydatabase];integrated security=SSPI; persist security info=False;packet size=4096"
                xmlobject = eConCall.CreateTransactionEntity(sConnectionString, xmldocument)
            Catch exp As eConnectException
                MsgBox(exp.ToString)
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            Finally
                eConCall.Dispose()
                MsgBox("done")
            End Try
        End Using
    End Sub
    Public Shared Sub SerializeObject(ByVal filename As String)
        Try
            Dim cust As String = "CUSTNMBR9"
            Dim econnect As New eConnectType
            Dim customer As New RMCustomerMasterType
            'Customer record
            Dim customerrecord As New taUpdateCreateCustomerRcd
            With customerrecord
                .CUSTNMBR = cust
                .CUSTNAME = "Customer Name"
                .ADRSCODE = "PRIMARY"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
                .UpdateIfExists = 1
            End With
            customer.taUpdateCreateCustomerRcd = customerrecord

            'Internet address
            Dim internetaddress(0) As taCreateInternetAddresses_ItemsTaCreateInternetAddresses
            Dim INERNETADDRESS1 As New taCreateInternetAddresses_ItemsTaCreateInternetAddresses
            With INERNETADDRESS1
                .ADRSCODE = "PRIMARY"
                .INET1 = "EMAIL"
                .Master_ID = cust
                .Master_Type = "CUS"
            End With
            internetaddress(0) = INERNETADDRESS1
            customer.taCreateInternetAddresses_Items = internetaddress

            'Address - Primary
            Dim adressarray(2) As taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            Dim addessobject1 As New taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addessobject1
                .CUSTNMBR = cust
                .ADRSCODE = "PRIMARY"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            adressarray(0) = addessobject1

            Dim addessobject2 As New taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addessobject2
                .CUSTNMBR = cust
                .ADRSCODE = "BILLTO"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            adressarray(1) = addessobject2

            Dim addessobject3 As New taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addessobject3
                .CUSTNMBR = cust
                .ADRSCODE = "SHIP2"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            adressarray(2) = addessobject3
            customer.taCreateCustomerAddress_Items = adressarray

            'Parent id
            Dim parentobject As New taCreateParentID
            With parentobject
                .CPRCSTNM = cust
                .NAALLOWRECEIPTS = 1
                .NACREDITCHECK = 0
                .UpdateIfExists = 1

            End With
            customer.taCreateParentID = parentobject

            ReDim Preserve econnect.RMCustomerMasterType(0)
            econnect.RMCustomerMasterType(0) = customer

            Dim fs As New FileStream(filename, FileMode.Create)
            Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
            Dim serializer As New XmlSerializer(GetType(eConnectType))
            serializer.Serialize(writer, econnect)
            writer.Close()

        Catch ex As ApplicationException
            MsgBox(ex.ToString)
        End Try
    End Sub

Adapted from Microsoft Dynamics GP eConnect Samples installed during eConnect installation. Line breaks are issued to fit script within screen. Remove line breaks.

THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR  PURPOSE

<taCreateParentID>

Element name Datatype Length Required Description
CPRCSTNM string 15 Y Corporate customer number
NAALLOWRECEIPTS i4 1 N Allow receipts entry for children of the national account
NACREDITCHECK i4 1 N Base credit check on consolidated national account
NAFINANCECHARGE i4 1 N Base finance charge on consolidated national account
NAHOLDINACTIVE i4 1 N Apply hold/inactive status of parent across national account
NADEFPARENTVEN i4 1 N Default parent vendor for children refund checks
UpdateIfExists i4 1 N Flag to allow customer data to be updated if it exists:
0=No;
1=Yes
RequesterTrx i4 2 N Requester transaction:
0=False;
1=True (if True, it populates the requester shadow table)

XML Element Reference extracted from eConnect Programmers reference manual for immediate reference.

XML File Generated:

<?xml version="1.0" ?>
<eConnect xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <RMCustomerMasterType>
    <eConnectProcessInfo xsi:nil="true"/>
    <taRequesterTrxDisabler_Items xsi:nil="true"/>
    <taUpdateCreateCustomerRcd>
      <CUSTNMBR>
        CUSTNMBR9
      </CUSTNMBR>
      <CUSTNAME>
        Customer Name
      </CUSTNAME>
      <ADRSCODE>
        PRIMARY
      </ADRSCODE>
      <ADDRESS1>
        Address 1
      </ADDRESS1>
      <ADDRESS2>
        Address 2
      </ADDRESS2>
      <ADDRESS3>
        Address 3
      </ADDRESS3>
      <CITY>
        City
      </CITY>
      <STATE>
        State
      </STATE>
      <ZIPCODE>
        ZIPCODE
      </ZIPCODE>
    </taUpdateCreateCustomerRcd>
    <taCreateCustomerAddress_Items>
      <taCreateCustomerAddress>
        <CUSTNMBR>
          CUSTNMBR9
        </CUSTNMBR>
        <ADRSCODE>
          PRIMARY
        </ADRSCODE>
        <ADDRESS1>
          Address 1
        </ADDRESS1>
        <ADDRESS2>
          Address 2
        </ADDRESS2>
        <ADDRESS3>
          Address 3
        </ADDRESS3>
        <CITY>
          City
        </CITY>
        <STATE>
          State
        </STATE>
        <ZIPCODE>
          ZIPCODE
        </ZIPCODE>
      </taCreateCustomerAddress>
      <taCreateCustomerAddress>
        <CUSTNMBR>
          CUSTNMBR9
        </CUSTNMBR>
        <ADRSCODE>
          BILLTO
        </ADRSCODE>
        <ADDRESS1>
          Address 1
        </ADDRESS1>
        <ADDRESS2>
          Address 2
        </ADDRESS2>
        <ADDRESS3>
          Address 3
        </ADDRESS3>
        <CITY>
          City
        </CITY>
        <STATE>
          State
        </STATE>
        <ZIPCODE>
          ZIPCODE
        </ZIPCODE>
      </taCreateCustomerAddress>
      <taCreateCustomerAddress>
        <CUSTNMBR>
          CUSTNMBR9
        </CUSTNMBR>
        <ADRSCODE>
          SHIP2
        </ADRSCODE>
        <ADDRESS1>
          Address 1
        </ADDRESS1>
        <ADDRESS2>
          Address 2
        </ADDRESS2>
        <ADDRESS3>
          Address 3
        </ADDRESS3>
        <CITY>
          City
        </CITY>
        <STATE>
          State
        </STATE>
        <ZIPCODE>
          ZIPCODE
        </ZIPCODE>
      </taCreateCustomerAddress>
    </taCreateCustomerAddress_Items>
    <taCreateInternetAddresses_Items>
      <taCreateInternetAddresses>
        <Master_Type>
          CUS
        </Master_Type>
        <Master_ID>
          CUSTNMBR9
        </Master_ID>
        <ADRSCODE>
          PRIMARY
        </ADRSCODE>
        <INET1>
          EMAIL
        </INET1>
      </taCreateInternetAddresses>
    </taCreateInternetAddresses_Items>
    <taCreateParentID>
      <CPRCSTNM>
        CUSTNMBR9
      </CPRCSTNM>
      <UpdateIfExists>
        1
      </UpdateIfExists>
    </taCreateParentID>
    <taParentIDChild_Items xsi:nil="true"/>
  </RMCustomerMasterType>
</eConnect>

 
Cheers!
Sanjay

eConnect – Customer, Address, internet info – Example

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization
Public Class econnectApplication
    Public Sub eConnectSend()
        'Serialized XML File         
        Dim xmldocument As String
        'Connection String         
        Dim sConnectionString As String
        'Result         
        Dim xmlobject As String
        Using eConCall As New eConnectMethods
            Try
                SerializeObject("xmlfile.xml ")
                Dim xmldoc As New Xml.XmlDocument
                xmldoc.Load("xmlfile.xml")
                xmldocument = xmldoc.OuterXml
                sConnectionString = "data source=[SQLSERVER];initial catalog=[COMPANY DATABASE];integrated security=SSPI; persist security info=False;packet size=4096"
                xmlobject = eConCall.CreateTransactionEntity(sConnectionString, xmldocument)
            Catch exp As eConnectException
                MsgBox(exp.ToString)
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            Finally
                eConCall.Dispose()
                MsgBox("done")
            End Try
        End Using
    End Sub
    Public Shared Sub SerializeObject(ByVal filename As String)
        Try
            Dim econnect As New eConnectType
            Dim customer As New RMCustomerMasterType
            'Customer record
            Dim customerrecord As New taUpdateCreateCustomerRcd
            With customerrecord
                .CUSTNMBR = "CUSTNMBR2"
                .CUSTNAME = "Customer Name"
                .ADRSCODE = "PRIMARY"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
                .Send_Email_Statements = 1
                .Send_Email_StatementsSpecified = True
            End With
            customer.taUpdateCreateCustomerRcd = customerrecord

            'Internet address
            Dim internetaddress(0) As taCreateInternetAddresses_ItemsTaCreateInternetAddresses
            Dim INERNETADDRESS1 As New taCreateInternetAddresses_ItemsTaCreateInternetAddresses
            With INERNETADDRESS1
                .ADRSCODE = "PRIMARY"
                .INET1 = "EMAIL"
                .Master_ID = "CUSTNMBR2"
                .Master_Type = "CUS"
            End With
            internetaddress(0) = INERNETADDRESS1
            customer.taCreateInternetAddresses_Items = internetaddress

            'Address - Primary
            Dim adressarray(2) As taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            Dim addessobject1 As New taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addessobject1
                .CUSTNMBR = "CUSTNMBR2"
                .ADRSCODE = "PRIMARY"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            adressarray(0) = addessobject1

            Dim addessobject2 As New taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addessobject2
                .CUSTNMBR = "CUSTNMBR2"
                .ADRSCODE = "BILLTO"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            adressarray(1) = addessobject2

            Dim addessobject3 As New taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addessobject3
                .CUSTNMBR = "CUSTNMBR2"
                .ADRSCODE = "SHIP2"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            adressarray(2) = addessobject3
            customer.taCreateCustomerAddress_Items = adressarray

            ReDim Preserve econnect.RMCustomerMasterType(0)
            econnect.RMCustomerMasterType(0) = customer

            Dim fs As New FileStream(filename, FileMode.Create)
            Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
            Dim serializer As New XmlSerializer(GetType(eConnectType))
            serializer.Serialize(writer, econnect)
            writer.Close()
        Catch ex As ApplicationException
            MsgBox(ex.ToString)
        End Try
    End Sub

Adapted from Microsoft Dynamics GP eConnect Samples installed during eConnect installation.

Line breaks are issued to fit script within screen. Remove line breaks.

THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR  PURPOSE

<taCreateInternetAddresses>

Element name Data type Length Required Description
Master_Type string 3 Y Master type:
CUS=Customer record;
ITM=Item record;
VEN=Vendor record;
CMP=Company record;
SLP=Salesperson record;
EMP=Employee record
Master_ID string 30 Y Master record ID
ADRSCODE string 15 N Address code—not required for item record and salesperson record
INET1 string 200 N E-mail address
INET2 string 200 N Web-site address
INET3 string 200 N FTP address
INET4 string 200 N Image
INET5 string 200 N Logon
INET6 string 200 N Password
INET7 string 200 N User-defined field 1
INET8 string 200 N User-defined field 2
INETINFO string 1000 N Internet information
Messenger_Address string 200 N Messenger address
EmailBccAddress string 1000 N Email BCC address
EmailCcAddress string 1000 N Email CC address
EmailToAddress string 1000 N Email to address

Extracted from eConnect Programmers reference Guide for immediate reference.

<?xml version="1.0" ?>
<eConnect xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <RMCustomerMasterType>
    <eConnectProcessInfo xsi:nil="true"/>
    <taRequesterTrxDisabler_Items xsi:nil="true"/>
    <taUpdateCreateCustomerRcd>
      <CUSTNMBR>
        CUSTNMBR6
      </CUSTNMBR>
      <CUSTNAME>
        Customer Name
      </CUSTNAME>
      <ADRSCODE>
        PRIMARY
      </ADRSCODE>
      <ADDRESS1>
        Address 1
      </ADDRESS1>
      <ADDRESS2>
        Address 2
      </ADDRESS2>
      <ADDRESS3>
        Address 3
      </ADDRESS3>
      <CITY>
        City
      </CITY>
      <STATE>
        State
      </STATE>
      <ZIPCODE>
        ZIPCODE
      </ZIPCODE>
    </taUpdateCreateCustomerRcd>
    <taCreateCustomerAddress_Items>
      <taCreateCustomerAddress>
        <CUSTNMBR>
          CUSTNMBR6
        </CUSTNMBR>
        <ADRSCODE>
          PRIMARY
        </ADRSCODE>
        <ADDRESS1>
          Address 1
        </ADDRESS1>
        <ADDRESS2>
          Address 2
        </ADDRESS2>
        <ADDRESS3>
          Address 3
        </ADDRESS3>
        <CITY>
          City
        </CITY>
        <STATE>
          State
        </STATE>
        <ZIPCODE>
          ZIPCODE
        </ZIPCODE>
      </taCreateCustomerAddress>
      <taCreateCustomerAddress>
        <CUSTNMBR>
          CUSTNMBR6
        </CUSTNMBR>
        <ADRSCODE>
          BILLTO
        </ADRSCODE>
        <ADDRESS1>
          Address 1
        </ADDRESS1>
        <ADDRESS2>
          Address 2
        </ADDRESS2>
        <ADDRESS3>
          Address 3
        </ADDRESS3>
        <CITY>
          City
        </CITY>
        <STATE>
          State
        </STATE>
        <ZIPCODE>
          ZIPCODE
        </ZIPCODE>
      </taCreateCustomerAddress>
      <taCreateCustomerAddress>
        <CUSTNMBR>
          CUSTNMBR6
        </CUSTNMBR>
        <ADRSCODE>
          SHIP2
        </ADRSCODE>
        <ADDRESS1>
          Address 1
        </ADDRESS1>
        <ADDRESS2>
          Address 2
        </ADDRESS2>
        <ADDRESS3>
          Address 3
        </ADDRESS3>
        <CITY>
          City
        </CITY>
        <STATE>
          State
        </STATE>
        <ZIPCODE>
          ZIPCODE
        </ZIPCODE>
      </taCreateCustomerAddress>
    </taCreateCustomerAddress_Items>
    <taCreateInternetAddresses_Items>
      <taCreateInternetAddresses>
        <Master_Type>
          CUS
        </Master_Type>
        <Master_ID>
          CUSTNMBR6
        </Master_ID>
        <ADRSCODE>
          PRIMARY
        </ADRSCODE>
        <INET1>
          EMAIL
        </INET1>
      </taCreateInternetAddresses>
    </taCreateInternetAddresses_Items>
    <taCreateParentID>
      <CPRCSTNM>
        CUSTNMBR6
      </CPRCSTNM>
    </taCreateParentID>
    <taParentIDChild_Items xsi:nil="true"/>
  </RMCustomerMasterType>
</eConnect>

 

 

Cheers!
Sanjay

eConnect Project References

Option 1

To add an eConnect class or enumeration to your .NET development project, use Visual Studio to add a reference to the eConnect assembly. To add a reference, complete the following steps:

  1. Open the Add Reference window. From the Visual Studio Project menu, click Add Reference. The Add Reference window opens and displays the .NET tab.
  2. Find the assembly. In the .NET tab, scroll the list of assemblies and click the eConnect assembly name. For example, click Microsoft.Dynamics.GP.eConnect.
  3. Add a reference to the assembly. To add the reference, click OK. The specified assembly is added to the list of references for your Visual Studio project. The Add Reference window closes.

Option 2

To add eConnect functionality, you add a reference in your .NET development project to one or more of the eConnect .NET assemblies. The assemblies are typically found in the following location.

C:\Program Files\Microsoft Dynamics\eConnect 12.0\API

The eConnect assemblies includes the following namespaces:

  • Microsoft.Dynamics.GP.eConnect Namespace
  • Microsoft.Dynamics.GP.eConnect.Serialization Namespace

Option 3

Connect to integration service : net.pipe://localhost/Microsoft/Dynamics/GP/eConnect/
Add a service reference to a Visual Studio project, the properties for the project must specify the target framework as .NET Framework 3.5.

Cheers!
Sanjay

 

 
 

 

eConnect – Customer Address Example

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization

Public Class econnectApplication
    Public Sub eConnectSend()
        'Serialized XML File
        Dim xmldocument As String

        'Connection String
        Dim sConnectionString As String

        'Result
        Dim xmlobject As String

        Using eConCall As New eConnectMethods
            Try
                SerializeObject("xmlfile.xml")
                Dim xmldoc As New Xml.XmlDocument
                xmldoc.Load("xmlfile.xml")
                xmldocument = xmldoc.OuterXml
                sConnectionString = "data source=[SQLSERVER];
                initial catalog=[COMPANYDB];
                integrated security=SSPI;
                persist security info=False;
                packet size=4096"
                xmlobject = eConCall.CreateTransactionEntity(
                               sConnectionString, 
                               xmldocument
                            )
            Catch exp As eConnectException
                MsgBox(exp.ToString)
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            Finally
                eConCall.Dispose()
                MsgBox("done")
            End Try
        End Using
    End Sub
    Public Shared Sub SerializeObject(ByVal filename As String)
        Try

            'Address record 1
            Dim addressobject(1) As 
               taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            Dim addressobj1 As New 
               taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addressobj1
                .CUSTNMBR = "CUSTNMBR"
                .ADRSCODE = "BILLTO"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            addressobject(0) = addressobj1

            'Address record 2
            Dim addressobj2 As New 
               taCreateCustomerAddress_ItemsTaCreateCustomerAddress
            With addressobj2
                .CUSTNMBR = "CUSTNMBR"
                .ADRSCODE = "SHIPTO"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With
            addressobject(1) = addressobj2

            Dim objecttype As New RMCustomerAddressType
            ReDim Preserve 
                   objecttype.taCreateCustomerAddress_Items(1)
            objecttype.taCreateCustomerAddress_Items=addressobject

            Dim eConnect As New eConnectType
            ReDim Preserve eConnect.RMCustomerAddressType(1)
            eConnect.RMCustomerAddressType(1) = objecttype

            Dim fs As New FileStream(filename, FileMode.Create)
            Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
            Dim serializer As New 
                  XmlSerializer(GetType(eConnectType))
            serializer.Serialize(writer, eConnect)
            writer.Close()
        Catch ex As ApplicationException
            MsgBox(ex.ToString)
        End Try
    End Sub

Adapted from Microsoft Dynamics GP eConnect Samples installed during eConnect installation.  

Line breaks are issued to fit script within screen. Remove line breaks.

THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR  PURPOSE

taCreateCustomerAddress

Element name Datatype Length Required Description
CUSTNMBR string 15 Y Customer number
ADRSCODE string 15 Y Address ID
SLPRSNID string 15 N Salesperson ID
UPSZONE string 3 N UPS zone
SHIPMTHD string 15 N Shipping method
TAXSCHID string 15 N Tax schedule
CNTCPRSN string 60 N Contact person
ADDRESS1 string 60 N Customer address one
ADDRESS2 string 60 N Customer address two
ADDRESS3 string 60 N Customer address three
COUNTRY string 60 N Customer country
CITY string 35 N Customer city
STATE string 29 N Customer state
ZIPCODE string 10 N Customer zip
PHNUMBR1 string 21 N Phone one
PHNUMBR2 string 21 N Phone two
PHNUMBR3 string 21 N Phone three
FAX string 21 N Fax
GPSFOINTEGRATIONID string 30 N Front office integration ID
INTEGRATIONSOURCE i4 2 N Integration source
INTEGRATIONID string 30 N Integration ID
CCode string 6 N Country code
LOCNCODE string 10 N Location code
SALSTERR string 15 N Sales territory
USERDEF1 string 20 N User defined 1
USERDEF2 string 20 N User defined 2
UpdateIfExists i4 1 N Flag to allow updates to customer data:
0=No not update;
1=Update if exists

Extracted from eConnect Programmers Guide for immediate reference

eConnect – Customer – Example

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization

Public Class econnectApplication
    Public Sub eConnectSend()
        'Serialized XML File
        Dim xmldocument As String

        'Connection String
        Dim sConnectionString As String

        'Result
        Dim xmlobject As String

        Using eConCall As New eConnectMethods
            Try
                SerializeObject("xmlfile.xml")
                Dim xmldoc As New Xml.XmlDocument
                xmldoc.Load("xmlfile.xml")
                xmldocument = xmldoc.OuterXml
                sConnectionString = "data source=[SQLSERVER];initial catalog=[COMPANYDB];integrated security=SSPI;persist security info=False;packet size=4096"
                xmlobject = eConCall.CreateTransactionEntity(
                                 sConnectionString, xmldocument
                            )
            Catch exp As eConnectException
                MsgBox(exp.ToString)
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            Finally
                eConCall.Dispose()
                MsgBox("done")
            End Try
        End Using
    End Sub
    Public Shared Sub SerializeObject(ByVal filename As String)
        Try
            'eConnect proc
            Dim xmlnodeobject As New taUpdateCreateCustomerRcd
            With xmlnodeobject
                .CUSTNMBR = "CUSTNMBR"
                .CUSTNAME = "Customer Name"
                .ADRSCODE = "PRIMARY"
                .ADDRESS1 = "Address 1"
                .ADDRESS2 = "Address 2"
                .ADDRESS3 = "Address 3"
                .CITY = "City"
                .STATE = "State"
                .ZIPCODE = "ZIPCODE"
            End With

            'eConnect Object type
            Dim objecttype As New RMCustomerMasterType
            objecttype.taUpdateCreateCustomerRcd = xmlnodeobject

            Dim eConnect As New eConnectType
            ReDim Preserve eConnect.RMCustomerMasterType(0)
            eConnect.RMCustomerMasterType(0) = objecttype
            Dim fs As New FileStream(filename, FileMode.Create)
            Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
            Dim serializer As New XmlSerializer(GetType(eConnectType))
            serializer.Serialize(writer, eConnect)
            writer.Close()
        Catch ex As ApplicationException
            MsgBox(ex.ToString)
        End Try
    End Sub

 

Adapted from Microsoft Dynamics GP eConnect Samples installed during eConnect installation.  

Line breaks are issued to fit script within screen. Remove line breaks.

THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR  PURPOSE

 

taUpdateCreateCustomerRcd

Element name Data type Length Required Description
CUSTNMBR string 15 Y Customer number
HOLD i4 1 N Hold status:
0=Not on hold;
1=On hold
Default is zero on new record
INACTIVE i4 1 N Inactive:
0=Active;
1=Inactive
Default is zero on new record
CUSTNAME string 64 N Customer name
SHRTNAME string 15 N Short name; if not passed in, default is CUSTNAME
STMTNAME string 64 N Statement name; if not passed in, default is CUSTNAME
CUSTCLAS string 15 N Customer class ID
CUSTPRIORITY i4 2 N Customer priority; valid input values 1 (none) to 100
 
Default is one on new record
ADRSCODE string 15 N Primary address ID
CNTCPRSN string 60 N Contact person
ADDRESS1 string 60 N Customer address one
ADDRESS2 string 60 N Customer address two
ADDRESS3 string 60 N Customer address three
CITY string 35 N City
STATE string 29 N State
ZIPCODE string 10 N Zip code
CCode string 6 N Country code
COUNTRY string 60 N Country
PHNUMBR1 string 21 N Phone one
PHNUMBR2 string 21 N Phone two
PHNUMBR3 string 21 N Phone three
FAX string 21 N Fax
UPSZONE string 3 N UPS zone
SHIPMTHD string 15 N Shipping method
TAXSCHID string 15 N Tax schedule ID
SHIPCOMPLETE i4 1 N Ship complete documents:
0=False;
1=True
Default is zero on new record
PRSTADCD string 15 N Primary ship to address code
PRBTADCD string 15 N Primary bill to address code
STADDRCD string 15 N Statement to address code
SLPRSNID string 15 N Salesperson ID
SALSTERR string 15 N Sales territory
USERDEF1 string 20 N User-defined one
USERDEF2 string 20 N User-defined two
COMMENT1 string 30 N Comment one
COMMENT2 string 30 N Comment two
CUSTDISC number 21 N Trade discount
PYMTRMID string 20 N Payment terms ID
DISGRPER i4 2 N Discount grace period
DUEGRPER i4 2 N Due date grace period
PRCLEVEL string 10 N Price level
NOTETEXT string 8000 N Note text
BALNCTYP i4 1 N Balance type:
0=Open item;
1=Balance forward
Default is zero on new record
FNCHATYP i4 2 N Finance charge type:
0=None;
1=Percent;
2=Amount
Default is zero for new record
FNCHPCNT number 21 N Finance charge percent; used if FNCHATYP=1
FINCHDLR number 21 N Finance charge dollar; used if FNCHATYP=2
MINPYTYP i4 2 N Minimum payment type:
0=No minimum;
1=Percent; 2=Amount
Default is zero for new record
MINPYPCT number 21 N Minimum payment percent; used if MINPYTYP=1
MINPYDLR number 21 N Minimum payment dollar amount; used if MINPYTYP=2
CRLMTTYP i4 2 N Credit limit type:
0=No credit;
1=Unlimited;
2=Amount
Default is zero on new record
CRLMTAMT number 21 N Credit limit amount; used if CRLMTTYP=2
CRLMTPER i4 2 N Credit limit period; used if CRLMTTYP=2 and the credit limit warning is used in Microsoft Dynamics GP application
CRLMTPAM number 21 N Credit limit period amount; used if CRLMTTYP=2 and the credit limit warning is used in Microsoft Dynamics GP application
MXWOFTYP i4 2 N Maximum write-off type: 0=Not allowed;
1=Unlimited;
2=Maximum
Default is zero for new record
MXWROFAM number 21 N Maximum write-off amount; used if MXWOFTYP=2
Revalue_Customer i4 1 N Revalue customer:
0=Do not revalue;
1=Revalue
Default is one for new record
Post_Results_To i4 2 N Post results to:
0=Receivables/Discount Account;
1=Sales offset
Default is zero on new records
ORDERFULFILLDEFAULT i4 1 N Order fulfillment shortage:
1=None;
2=Back order remaining;
3=Cancel remaining
Default is one on new record
INCLUDEINDP i4 1 N Include in demand planning: 0=Do not include;
1=Include
Default is one on new record
CRCARDID string 15 N Credit card ID
CRCRDNUM string 20 N Credit card number
CCRDXPDT datetime 16 N Credit card expiration date
BANKNAME string 30 N Bank name
BNKBRNCH string 20 N Bank branch
USERLANG i4 2 N User language; default is zero on new record
TAXEXMT1 string 25 N Tax exempt one
TAXEXMT2 string 25 N Tax exempt two
TXRGNNUM string 25 N Tax registration number
CURNCYID string 15 N Currency ID
RATETPID string 15 N Rate type ID
STMTCYCL i4 2 N Statement Cycle:
1=No Statement;
2=Weekly;
3=Biweekly;
4=Semimonthly;
5=Monthly;
6=Bimonthly;
7=Quarterly
KPCALHST i4 1 N Maintain history—calendar year:
0=Do not maintain history;
1=Maintain history
Default is 1 on new record
KPERHIST i4 1 N Maintain history—fiscal year:
0=Do not maintain history;
1=Maintain history
Default is 1 on new record
KPTRXHST i4 1 N Maintain history—transaction:
0=Do not maintain history;
1=Maintain history
Default is 1 on new record
KPDSTHST i4 1 N Maintain history—distribution:
0=Do not maintain history;
1=Maintain history
Default is 1 on new record
Send_Email_Statements i4 1 N Send e-mail statements:
0=Do not sent statements;
1=Send statements
Default is zero on new record
ToEmail_Recipient string 80 N To email recipient; separate each recipient with a semicolon
CcEmail_Recipient string 80 N Carbon copy email recipient; separate each recipient with a semicolon
BccEmail_Recipient string 80 N Blind carbon copy email recipient; separate each recipient with a semicolon
CHEKBKID string 15 N Checkbook ID
DEFCACTY i4 2 N Cash account from: 0=Checkbook;
1=Customer
Default is zero on new record
RMCSHACTNUMST string 75 N Cash account; only valid if DEFCACTY=1
RMARACTNUMST string 75 N Accounts receivable account
RMSLSACTNUMST string 75 N Sales account
RMCOSACTNUMST string 75 N Cost of sales account
RMIVACTNUMST string 75 N Inventory account
RMTAKACTNUMST string 75 N Terms discount taken account
RMAVACTNUMST string 75 N Terms discount available account
RMFCGACTNUMST string 75 N Finance charges account
RMWRACTNUMST string 75 N Write-offs account
RMSORACTNUMST string 75 N Sales order returns account
RMOvrpymtWrtoffACTNUMST string 75 N Overpayment write-offs account
GPSFOINTEGRATIONID string 30 N Front office integration ID
INTEGRATIONSOURCE i4 2 N Integration source
INTEGRATIONID string 30 N Integration ID
UseCustomerClass i4 1 N Flag to have class setting roll down to elements not passed in; uses the CUSTCLAS class to roll down
CreateAddress i4 1 N Flag to allow a primary address code to be created on the fly:
0=Do not create address code;
1=Create address code
UpdateIfExists i4 1 N Flag to allow customer data to be updated if it exists:
0=Do not update;
1=Update if record exists;
2=Create if record does not exist and exits without error if record does exist
RequesterTrx i4 2 N Requester transaction:
0=False;
1=True (if True, it populates the requester shadow table)

Extracted from GP eConnect Programmers Guide

eConnect – Customer Class – Example

Imports System
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic
Imports Microsoft.Dynamics.GP.eConnect
Imports Microsoft.Dynamics.GP.eConnect.Serialization

Public Class econnectApplication
    Public Sub eConnectSend()
        'Serialized XML File
        Dim xmldocument As String

        'Connection String
        Dim sConnectionString As String

        'Result
        Dim xmlobject As String

        Using eConCall As New eConnectMethods
            Try
                SerializeObject("xmlfile.xml ")
                Dim xmldoc As New Xml.XmlDocument
                xmldoc.Load("xmlfile.xml")
                xmldocument = xmldoc.OuterXml
                sConnectionString = "data source=[SQLSERVER];
                                     initial catalog=[COMPANYDB];
                                     integrated security=SSPI;
                                     persist security info=False;
                                     packet size=4096"
                xmlobject = eConCall.CreateTransactionEntity(
                                       sConnectionString, 
                                       xmldocument
                            )
            Catch exp As eConnectException
                MsgBox(exp.ToString)
            Catch ex As System.Exception
                MsgBox(ex.ToString)
            Finally
                eConCall.Dispose()
                MsgBox("done")
            End Try
        End Using
    End Sub
    Public Shared Sub SerializeObject(ByVal filename As String)
        Try
         'eConnect proc
         Dim xmlnodeobject As New taCreateCustomerClass
         With xmlnodeobject
             .CLASSID = "CC"
             .CLASDSCR = "Customer Class"
         End With

         Dim objecttype As New RMCustomerClassType
         objecttype.taCreateCustomerClass = xmlnodeobject

         Dim eConnect As New eConnectType
         ReDim Preserve eConnect.RMCustomerClassType(0)
         eConnect.RMCustomerClassType(0) = objecttype
         Dim fs As New FileStream(filename, FileMode.Create)
         Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
         Dim serializer As New XmlSerializer(GetType(eConnectType))
            serializer.Serialize(writer, eConnect)
            writer.Close()
         Catch ex As ApplicationException
            MsgBox(ex.ToString)
         End Try
    End Sub
End Class

Adapted from Microsoft Dynamics GP eConnect Samples installed during eConnect installation.  

Line breaks are issued to fit script within screen. Remove line breaks.

THIS CODE AND INFORMATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR  PURPOSE

 

 

<taCreateCustomerClass>

Element name Datatype Length Required Description
CLASSID string 15 Y Class ID
CLASDSCR string 30 N Class description
CRLMTTYP i4 2 N Credit limit type:
0=No credit;
1=Unlimited;
2=Amount
CRLMTAMT number 21 N Credit amount
CRLMTPER i4 2 N Credit limit period
CRLMTPAM number 21 N Credit limit period amount
DEFLTCLS i4 1 N Default class
BALNCTYP i4 2 N Balance type:
0=Open item;
1=Balance forward
CHEKBKID string 15 N Checkbook ID
TAXSCHID string 15 N Tax schedule ID
SHIPMTHD string 15 N Shipping method
PYMTRMID string 20 N Payment term ID
CUSTDISC i4 2 N Customer discount/trade discount
MINPYTYP i4 2 N Minimum payment type:
0=No minimum;
1=Percent;
2=Amount
MINPYDLR number 21 N Minimum payment dollar
MINPYPCT i4 2 N Minimum payment percent
MXWOFTYP i4 2 N Maximum write-off type:
0=Not allowed;
1=Unlimited;
2=Maximum
MXWROFAM number 21 N Maximum write-off amount
FNCHATYP i4 2 N Finance charge amount type:
0=None;
1=Percent;
2=Amount
FINCHDLR number 21 N Finance charge dollar
FNCHPCNT i4 2 N Finance charge percent
PRCLEVEL string 10 N Price level
CURNCYID string 15 N Currency ID
RATETPID string 15 N Rate ID
DEFCACTY i4 2 N Cash account from:
0=Checkbook;
1=Customer
CASHACCT string 75 N Cash account
ACCTRECACCT string 75 N Account Receivable account
SALESACCT string 75 N Sales account
COSTOFSALESACCT string 75 N Cost of sales account
IVACCT string 75 N Inventory account
TERMDISCTAKENACCT string 75 N Terms discount taken account
TERMDISCAVAILACCT string 75 N Terms discount available account
FINCHRGACCT string 75 N Finance charges account
WRITEOFFACCT string 75 N Write-off account
SALESORDERRETACCT string 75 N Sales order returns account
SALSTERR string 15 N Sales territory
SLPRSNID string 15 N Sales person ID
STMTCYCL i4 2 N Statement cycle:
1=No statement;
2=Weekly;
3=Biweekly;
4=Semimonthly;
5=Monthly;
6=Bimonthly;
7=Quarterly
KPCALHST i4 1 N Keep calendar history:
0=False;
1=True
KPDSTHST i4 1 N Keep distribution history:
0=False;
1=True
KPERHIST i4 1 N Keep period history:
0=False;
1=True
KPTRXHST i4 1 N Keep transaction history:
0=False;
1=True
DISGRPER i4 2 N Discount grace period
DUEGRPER i4 2 N Due date of grace period
Revalue_Customer i4 1 N Revalue customer:
0=False;
1=True
Post_Results_To i4 2 N Post results to: 0=Receivables/discount account 1=Sales offset account
ORDERFULFILLDEFAULT i4 1 N Order fulfillment shortage default:
1=None;
2=Back order remaining;
3=Cancel remaining
CUSTPRIORITY i4 2 N Customer priority; valid input values are 1 (none) to 100
RMOvrpymtWrtoffAcct string 75 N RM overpayment write-off account

 Extracted from GP eConnect Programmers Guide

Cheers!
Sanjay