Updates the specified sales return object, storing the current values in the database.
Parameter |
Type |
Description |
---|---|---|
salesReturn |
The sales return object that is being updated. |
|
context |
Specifies information about how the method will be called. |
|
policy |
Specifies the set of behaviors and behavior options to be applied during the operation. |
The following C# example retrieves the sales return with the sales return key value “STDINV2257” and sets the comment property to “Return was approved”. The UpdateSalesReturn operation saves the new comment and all the sales return object’s properties to the database.
Legacy endpoint
using System; using System.Collections.Generic; using System.Text; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; SalesDocumentKey salesReturnKey; SalesReturn salesReturn; Policy salesReturnPolicy; // Create an instance of the service DynamicsGP wsDynamicsGP = new DynamicsGP(); // Be sure that default credentials are used wsDynamicsGP.UseDefaultCredentials = true; // Create a context with which to call the service context = new Context(); // Specify which company to use (sample company) companyKey = new CompanyKey(); companyKey.Id = (-1); // Set up the context object context.OrganizationKey = (OrganizationKey)companyKey; // Create a Sales Return key and specify the sales return salesReturnKey = new SalesDocumentKey(); salesReturnKey.Id = "STDINV2257"; // Retrieve the sales return object salesReturn = wsDynamicsGP.GetSalesReturnByKey(salesReturnKey, context); // Set the comment property salesReturn.Comment = "Return was approved"; // Get the update policy for sales returns salesReturnPolicy = wsDynamicsGP.GetPolicyByOperation("UpdateSalesReturn", context); // Update the sales return object wsDynamicsGP.UpdateSalesReturn(salesReturn, context, salesReturnPolicy); } } }
Native endpoint
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; SalesDocumentKey salesReturnKey; SalesReturn salesReturn; Policy salesReturnPolicy; // Create an instance of the service DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(); // Create a context with which to call the service context = new Context(); // Specify which company to use (sample company) companyKey = new CompanyKey(); companyKey.Id = (-1); // Set up the context object context.OrganizationKey = (OrganizationKey)companyKey; // Create a Sales Return key and specify the sales return salesReturnKey = new SalesDocumentKey(); salesReturnKey.Id = "STDINV2257"; // Retrieve the sales return object salesReturn = wsDynamicsGP.GetSalesReturnByKey(salesReturnKey, context); // Set the comment property salesReturn.Comment = "Return was approved"; // Get the update policy for sales returns salesReturnPolicy = wsDynamicsGP.GetPolicyByOperation("UpdateSalesReturn", context); // Update the sales return object wsDynamicsGP.UpdateSalesReturn(salesReturn, context, salesReturnPolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }