Using CreateEntity for new records

The eConnectClient class of the eConnect Integration Service includes a methods to create, update, delete, and retrieve Microsoft Dynamics GP data. In addition, the class includes methods you can use to retrieve and restore Microsoft Dynamics GP document numbers.

To understand how to use the eConnectClients class, use the following steps to add a customer to Microsoft Dynamics GP. Notice how the CreateEntity method of the eConnectClient class creates a customer using XML from a file.

Add the service namespace to the project

Before you begin, you must add a service reference to the eConnect Integration Service of your application. After you add the service reference, add the namespace of the reference.

The following C# example shows how to add a using statement for the service reference. ServiceTestApp is the name of the application project and eConnectIntegrationService is the name given to the service reference.

using ServiceTestApp.eConnectIntegrationService;

Instantiate an eConnectClient object

To begin, instantiate an eConnectClient object. The following C# example shows how to instantiate an eConnectClient object:

// Instantiate an eConnectClient object
eConnectClient eConnectObject = new eConnectClient();

Load the eConnect XML document

The following C# example shows how to use the XML text from a file as the source of the eConnect XML document. Notice how text from the specified file is loaded into a .NET XmlDocument object.

// Use the XML document in the specified file to create 
// a string representation of the customer
XmlDocument newCustDoc = new XmlDocument();
newCustDoc.Load("CustomerCreate.xml");
string newCustomerDocument = newCustDoc.OuterXml;

Create an eConnect connection string

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 C# example shows how to creates a connection string:

//Create a connection string
string connectionString = "Data Source=localhost;Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=TWO;";

Submit the eConnect document

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.

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 C# example uses the CreateEntity method to submit an eConnect XML document. Notice the following: