web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Update Sales Order and order item table using eConnect

(0) ShareShare
ReportReport
Posted on by 29

Hi When I update the sales order and orderLine item using eConnect i get this error.

select * from SOP10100

select * from SOP10200


Microsoft.Dynamics.GP.eConnect.eConnectException
Message : If UpdateExisting is set to 1 than a transaction document number must be provided.
StackTrace : at Microsoft.Dynamics.GP.eConnect.ServiceProxy.CreateEntity(String connectionString, String xml)
at Microsoft.Dynamics.GP.eConnect.eConnectMethods.EntityImportImplementation(String connectionString, String sXML, Boolean isTransaction)
at Microsoft.Dynamics.GP.eConnect.eConnectMethods.CreateEntity(String connectionString, String sXML)
at DynamicsGP.Program.Main(String[] args) in D:\ProjectWork\MST_Finecal_DataMigration_Hiten_4July2019_WIP\DynamicsGPProject\DynamicsGP\DynamicsGP\Program.cs:line 596

Below is my code.

using (eConnectMethods eConnectMethods = new eConnectMethods())
{
try
{
string connectionString = @"data source=10.219.225.154;initial catalog=" + ConfigurationManager.AppSettings["GPDatabaseName"] + ";Integrated Security=SSPI;Persist Security Info=False;";


#region Order Code

Console.WriteLine("Start Creating order.");
DateTimeFormatInfo dateFormat = new CultureInfo("en-US").DateTimeFormat;

SOPTransactionType salesOrder = new SOPTransactionType();

taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert();

taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] LineItems = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[1];
//List<taSopLineIvcInsert_ItemsTaSopLineIvcInsert> LineItems = new List<taSopLineIvcInsert_ItemsTaSopLineIvcInsert>();


salesLine.CUSTNMBR = "OCCUST_914";
salesLine.SOPTYPE = 2;
salesLine.SOPNUMBE = "ORD0128840";
salesLine.DOCID = "STD ORDER";
salesLine.QUANTITY = 2;
salesLine.ITEMNMBR = "10069266";
salesLine.UNITPRCE = 10;
salesLine.XTNDPRCE = 20;
salesLine.DOCDATE = System.DateTime.Today.ToString("dd/MM/yyyy", dateFormat);
salesLine.NONINVEN = 0;
salesLine.LOCNCODE = "LABELS";
salesLine.ADDRESS1 = "Mekhmandarov street, 72, flat 53";
salesLine.UpdateIfExists = 1;
salesLine.LNITMSEQ = 16384;
salesLine.RecreateDist = 0;
LineItems[0] = salesLine;

salesOrder.taSopLineIvcInsert_Items = LineItems;

salesHdr.SOPTYPE = 2;
salesHdr.DOCID = "STD ORDER";
salesHdr.BACHNUMB = "B1";
salesHdr.DOCDATE = System.DateTime.Today.ToString("dd/MM/yyyy", dateFormat);
salesHdr.CUSTNMBR = "OCCUST_914";
salesHdr.SUBTOTAL = 20;
salesHdr.DOCAMNT = 20;
salesHdr.LOCNCODE = "LABELS";
salesHdr.UpdateExisting = 1;


//salesHdr.USINGHEADERLEVELTAXES = 0;


salesOrder.taSopHdrIvcInsert = salesHdr;
eConnectType eConnect = new eConnectType();
SOPTransactionType[] MySopTransactionType = new SOPTransactionType[1] { salesOrder };

eConnect.SOPTransactionType = MySopTransactionType;

// Serialize the master vendor type in memory.
MemoryStream memoryStream = new MemoryStream();
XmlSerializer xmlSerializer = new XmlSerializer(eConnect.GetType());


// Serialize the eConnectType.
xmlSerializer.Serialize(memoryStream, eConnect);

// Reset the position of the memory stream to the start.
memoryStream.Position = 0;

// Create an XmlDocument from the serialized eConnectType in memory.
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(memoryStream);
memoryStream.Close();
Console.WriteLine("Call eConnect method.");
// Call eConnect to process the XmlDocument.
eConnectMethods.CreateEntity(connectionString, xmlDocument.OuterXml);

//string salesOrderDocID = eConnectMethods.CreateTransactionEntity(connectionString, xmlDocument.OuterXml);

//Console.WriteLine("Successfully created sales order {0}.", salesOrderDocID);
Console.WriteLine("Successfully created sales order");

#endregion

#region Customer Code

//InsertUpdateCustomer(objOpenCartCustomers, connectionString, eConnectMethods);

#endregion
}
catch (Exception ex)
{
Console.WriteLine("Error Ocured.");
Console.WriteLine("Exception occured: " + ex.Message);
WriteErrorToFile(ex);
}
finally
{
eConnectMethods.Dispose();
}
}

Please share example if any one have.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Craig Fuller Profile Picture
    411 on at
    RE: Update Sales Order and order item table using eConnect

    I'm totally going out on a limb here as I don't know eConnect but glancing through your post and reading the error returned, don't you need to specify the order number in the header section as well?

    Like:

    salesHdr.SOPNUMBE = "ORD0128840";

  • Tim Wappat Profile Picture
    5,711 on at
    RE: Update Sales Order and order item table using eConnect

    Add a line.

    salesHdr.CUSTNMBR = "OCCUST_914";

    before the line...

    salesHdr.SOPTYPE = 2;

    Tim.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Victoria Yudin Profile Picture

Victoria Yudin 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans