Share via


CreateEntity Method

Creates a record from an eConnect XML document.

Class

Microsoft.Dynamics.GP.eConnect.eConnectMethods

Syntax

public bool CreateEntity(string connectionString, string sXML)
Parameters

Name

Data type

Description

connectionString

string

Specifies your data server and database.

sXML

string

An eConnect XML document.

Return Value

Type: boolean

The method returns a boolean value that indicates whether the XML document was successfully created. A return value of True indicates the operation succeeded.

Remarks

Use the CreateEntity method to create new data records in Microsoft Dynamics GP. For example, use CreateEntity to add a new customer or vendor.

To submit a document, create a string that represents the eConnect XML document. Use the string as the sXML parameter.

If an error occurs, the method throws an eConnectException, application exception, or exception.

Examples

The following C# code example creates a customer record from XML in a file named CustomerCreate.xml. Notice how the CreateEntity method returns a boolean value.

// Use an XML document to create a string representation of the customer
XmlDocument newCustDoc = new XmlDocument();
newCustDoc.Load("CustomerCreate.xml");
newCustomerDocument = newCustDoc.OuterXml;
// Specify the Microsoft Dynamics GP server and database in
// the connection string
sConnectionString = @"data source=MySrvr;initial catalog=TWO;
    integrated security=SSPI;persist security info=False;
    packet size=4096";
// Use the CreateEntity method
bool testResult = e.CreateEntity(sConnectionString, newCustomerDocument);

See Also