Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

How to select default company while create sales order via eConnect?

(0) ShareShare
ReportReport
Posted on by

Hi,

I was using Dynamics GP 10.0, and have two companies. One is TEST company, and another one is LIVE PRODUCTION company. We're implementing eConnect now and decide to test it on TEST company.

 

This is eConnect code we use to create a sales order in the Dynamics GP.

 

using (eConnectMethods eConnectMethods = new eConnectMethods())
                {
                    taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] LineItems = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[lstItemsDet.Count];
                    SOPTransactionType salesOrder = new SOPTransactionType();
                    taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert();

                    int lineItemCount = 0;

                    foreach (var item in lstItemsDet)
                    {
                        taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
                        salesLine.CUSTNMBR = CustomerID;
                        salesLine.SOPTYPE = 2;
                        salesLine.DOCID = DocID;
                        salesLine.QUANTITY = item.Quantity;
                        salesLine.ITEMNMBR = item.ItemNo;
                        salesLine.UNITPRCE = item.UnitPrice;
                        salesLine.XTNDPRCE = item.UnitPrice * item.Quantity;
                        salesLine.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy");
                        salesLine.LOCNCODE = DefSiteID;
                        salesLine.SOPNUMBE = NextSoNumber;

                        LineItems[lineItemCount] = salesLine;
                        lineItemCount++;
                    }

                    salesHdr.CUSTNMBR = CustomerID;
                    salesHdr.SOPTYPE = 2;
                    salesHdr.DOCID = DocID;
                    salesHdr.BACHNUMB = BatchID;
                    salesHdr.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy");
                    salesHdr.LOCNCODE = DefSiteID;
                    salesHdr.SUBTOTAL = amount;
                    salesHdr.DOCAMNT = amount;
                    salesHdr.SOPNUMBE = NextSoNumber;
                    salesHdr.PRSTADCD = PrimaryShipTo;

                    salesHdr.USINGHEADERLEVELTAXES = 0;
                    salesOrder.taSopHdrIvcInsert = salesHdr;
                    salesOrder.taSopLineIvcInsert_Items = LineItems;

                    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();

                    // Call eConnect to process the XmlDocument.
                    eConnectMethods.eConnect_EntryPoint(connectionString, EnumTypes.ConnectionStringType.SqlClient, xmlDocument.OuterXml, EnumTypes.SchemaValidationType.None, string.Empty);
                }

I know it'll work and create a sales order, but in which company it'll create it? This should not create on the LIVE PRODUCTION COMPANY. 

How to find what company it will take or how to change the default company on eConnect?

 

P.S:  I got an error "This company does not have access to this Currency ID or is Inactive". I enabled currency IDs only for the test company and disabled for the live production company. Since the error clearly states, I am afraid, it is linking with live company and not with the production company. How can I change it test company?

Thanks in advance.

*This post is locked for comments

  • soma Profile Picture
    24,410 on at
    RE: How to select default company while create sales order via eConnect?

    Always Welcome...........:)

  • Community Member Profile Picture
    on at
    RE: How to select default company while create sales order via eConnect?

    Hey Soma,

    Thanks. Yes, there's a database called 'Test' on SQL Server. When I used this catalog on connection string, it started working.

    Mohamed Thaufeeq

  • Verified answer
    soma Profile Picture
    24,410 on at
    RE: How to select default company while create sales order via eConnect?

    You need to specify the Company database name in connection string to the function "eConnectMethods.eConnect_EntryPoint".

    What is value passed to this below parameter "connectionString"?

    eConnectMethods.eConnect_EntryPoint(connectionString, EnumTypes.ConnectionStringType.SqlClient, xmlDocument.OuterXml, EnumTypes.SchemaValidationType.None, string.Empty);

     

    This is normal SQL connection coding. Try the below.

    string connectionString= "data source=servername;initial catalog=TWO;integrated security=SSPI;persist security info=False;packet size=4096";

    Note: Specify your company database instead of TWO and pass this connectionString value to the function eConnect_EntryPoint.

    Hope this helps!!!

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Almas Mahfooz Profile Picture

Almas Mahfooz 3 User Group Leader

Featured topics

Product updates

Dynamics 365 release plans