Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

UpdateSalesOrder web method issue

(0) ShareShare
ReportReport
Posted on by

Hello,

Thank you in advance for any help/insight.

I built a very simple application which updates a sales batch for SOPTYPE: 2 documents based on a set of exterior rules.  I am using the UpdateSalesOrder web method with the Update Sales Order Policy as seen below.

The issue I am facing is that whenever an order with a payment is updated, a new GL entry is generated at the time of batch update.  The previous entry is being "voided" and replaced with a new one.  When we tested posting the "voided" GL entry, it brought the checkbook account balance up, and this does not seem right.

Is there a way to suppress this behavior?

 201500701_5F00_UpdateSalesOrder.png

Regards,

Michal

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    on at
    RE: UpdateSalesOrder web method issue

    Just in case anyone is wondering what went wrong:

    SCOPE:

    I understand that you're using Web Services for Dynamics GP 2013 to update sales batches. Whenever the order with a payment is updated you're noticing that a new entry is made in the GL module. For example, updating the batch an existing order is assigned to creates additional records in the GL10000 and GL10001 table.

    ASSESSMENT:

    Looking at your code it appears that you're actually changing the Customer PO Number to 'TEST". The Batch lines have been commented out.

    I performed some testing, first with the Native example of UpdateSalesOrder from the SDK which just adds a comment to an existing order. This worked just fine for me, so I copied in your code and tested again. I just needed to change how you're passing the company ID and SOP Number. It ran and updated the Customer PO Number just fine.

    When I compare the records in the GL10000 before and after I ran your code the number remained the same.

    I was just working with a Sales Order without a payment, so I entered a payment on it. Once the Payment was entered and the Order saved a new line was written to the GL10000 and 2 lines written to GL10001.

    I then ran your code again to change the Customer PO Number to TEST2. When I look at the GL10000 there are 2 new records and the GL10001 has 4 new records. It looks like the process of running that created 2 new GL batches, each containing the 2 distributions from my payment.

    So it looks like I can reproduce your issue.

    Looking at the Sales Payment Work and History (SOP10103) what appear to actually be happening is that the existing payment is being voided out and a new payment is created. Mine incremented from PYMNT000000000275 to PYMNT000000000276 when I ran another update to set Customer PO Number to TEST3. This also added another 2 and 4 records to GL10000 and GL10001 respectively.

    This is expected behavior from eConnect in regards to payments and orders. Because payments on orders are posted on saving the document, eConnect removes the payments on the document before modifying it. To do this, it essentially reverses them out. Once the document is updated, it then recreates the payment again (with a new payment number). Everything should "net" out the same however there will be extra documents to process (the multiple payments now) due to this process.

    When I looked at the resulting batches and the JEs that they hold it does appear that it is reversing out the transactions. For example, the first payment I entered against my Sales Order was for $100. When I look at that transaction it's a $100 credit against 000-1100-00 and a $100 debit against 000-2740-00. When I look at the JE associated with the next payment that has been created, SLSDP00000005, those values are flipped, essentially cancelling out the first JE. That's why 2 batches/JEs are created each time I update the order, one to cancel out the previous payment and another to create the new payment. While this means more batches to post everything should total out the same.

    I have found two cases where the customer used straight eConnect, which has much more flexibility in terms of what can be sent to the XML without the behaviors and policies of Web Services altering things.

    Another approach that I just saw, but have not tested, would be to handle the total payment on the order in your application code and then set this amount to the PaymentAmount property of the SalesOrder object. Since the Web Services XSLT file only looks at the PaymentAmount and not the DepositAmount, you would take the existing amounts and then add them to set the PaymentAmount. The below should make more sense. Then to avoid the existing payments to be voided you will null the existing Payments array.

    Code snippets to retrieve and update an existing order with existing payments:

    // Create a sales document key

    salesOrderKey = new SalesDocumentKey();

    salesOrderKey.Id = "FIORA0002";

    // Retrieve the sales order

    salesOrder = wsDynamicsGP.GetSalesOrderByKey(salesOrderKey, context);

    decimal existingDepositAmount = salesOrder.DepositAmount.Value;

    decimal existingPaymentAmount = salesOrder.PaymentAmount.Value;

    if (salesOrder.Payments != null)

    {

    salesOrder.Payments = null;

    }

  • Community Member Profile Picture
    on at
    RE: UpdateSalesOrder web method issue

    Follow up:

    Whenever we are updating an order, the associated payment is removed and replaced with a new one.  I do not understand this behavior.  Here is the code:

    CompanyKey companyKey;

                               Context context;

                               SalesDocumentKey salesOrderKey;

                               SalesOrder salesOrder;

                               //SalesUserDefined salesUserDef;

                               BatchKey OrderBatchKey;

                               Policy salesOrderUpdatePolicy;

                               CommentKey OrderCommentKey;

                               // Create an instance of the web service

                               DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

                               // Create a context with which to call the web service

                               context = new Context();

                               // Specify which company to use (sample company)

                               companyKey = new CompanyKey();

                               companyKey.Id = sopeval.Properties.Settings.Default.CompanyID;

                               // Set up the context object

                               context.OrganizationKey = (OrganizationKey)companyKey;

                               context.CultureName = "en-US";

                               // Create a sales document key for the sales order

                               salesOrderKey = new SalesDocumentKey();

                               salesOrderKey.Id = sopnumbe;

                               // Retrieve the sales order

                               salesOrder = wsDynamicsGP.GetSalesOrderByKey(salesOrderKey, context);

                               // Create a batch key

                               //OrderBatchKey = new BatchKey();

                               //OrderBatchKey.Id = batch;

                               // Set the batch key property of the sales order object

                               //salesOrder.BatchKey = OrderBatchKey;

                               salesOrder.CustomerPONumber = 'TEST";

                               // Get the create policy for the sales order object

                               salesOrderUpdatePolicy = wsDynamicsGP.GetPolicyByOperation("UpdateSalesOrder", context);

                               // Update the sales order

                               wsDynamicsGP.UpdateSalesOrder(salesOrder, context, salesOrderUpdatePolicy);

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,863 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans