The eConnectMethods class enables your .NET application to add new data records in Microsoft Dynamics GP. To create a record, use the following methods:
Method |
Description |
---|---|
CreateEntity |
Creates a record using information from an eConnect XML document. Use CreateEntity to add data entities like customers or vendors. You specify the type of record to create with a parameter that represents an eConnect XML document. If the operation succeeds, the method returns True as a boolean value. |
CreateTransactionEntity |
Create a transaction using information from an eConnect XML document. Use CreateTransactionEntity for transaction documents like sales orders or inventory transactions. You specify the type of transaction to create with a parameter that represents an eConnect XML document. If the operation succeeds, the method returns an XML string that represents the eConnect XML document that was created. |
The eConnectMethods class also includes methods to update or delete existing records in Microsoft Dynamics GP. To use these methods, you must supply the eConnect XML document for the specified operation and document type.
To create, update, and delete or void a record in Microsoft Dynamics GP, you must create an XML string for your eConnect XML document. The following are the most common techniques for creating this string.
To work with eConnect, the text that is loaded into the XmlDocument object must be a valid eConnect XML document. |
For more information about eConnect XML documents, see . eConnect XML document structure .
The following steps show how to use the CreateEntity method to create a record using XML from a textbox control.
To begin, instantiate an eConnectMethods object. The following Visual Basic example shows how to instantiate an eConnectMethods object:
'Instantiate an eConnectMethods object Dim eConnectObject As New eConnectMethods
The following Visual Basic example shows how to use the XML text from a textbox control as the source of the eConnect XML document. Notice how text from the specified control is loaded into a .NET XmlDocument object.
'Load the text from the textbox control into an XmlDocument object Dim xmlDoc As XmlDocument xmlDoc.LoadXml(XmlDoc_TextBox.Text)
The CreateEntity method requires an eConnect connection string. You use the connection string to specify the Dynamics GP data server and the company database.
For information about eConnect connection strings, see the eConnect Installation chapter of the eConnect Installation and Administration Guide.
The following Visual Basic example shows how to creates a connection string:
'Set the connection string 'This connection string uses integrated security to connect to the 'TWO database on the local computer Dim ConnectionString As String ConnectionString = "Data Source=localhost;Integrated Security=SSPI;" _ & "Persist Security Info=False;Initial Catalog=TWO;"
Use the CreateEntity method to submit the document to the eConnect business objects. To call the CreateEntity method, supply parameters that specify the connection string, and the eConnect XML document string.
For more information about eConnect_EntryPoint method, see eConnect_EntryPoint Method .
The CreateEntity method returns a boolean value that indicates whether the XML document was successfully submitted. A return value of True indicates the operation succeeded.
The following Visual Basic example uses the CreateEntity method to submit an eConnect XML document. Notice the following:
'If eConnectResult is TRUE, the XML document was successfully submitted Dim eConnectResult As Boolean eConnectResult = eConnectObject.CreateEntity(ConnectionString, _ xmlDoc.OuterXml)