CreateReturnMaterialAuthorization
Description
This method creates a new return material authorization.
Parameters
Parameter |
Type |
Description |
---|---|---|
returnMaterialAuthorization |
The return material authorization object being created. |
|
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. |
Interfaces
- Dynamics GP
- Field Service
Examples
The following C# example creates a return material authorization document. The example populates the required Key, ReturnWarehouseKey, ReturnTypeKey, CustomerKey, and ShipToAddressKey properties. All other return material authorization properties are set to default values. The CreateReturnMaterialAuthorization operation saves the new return material authorization document.
** 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; ReturnMaterialAuthorization returnMaterialAuthorization; ServiceDocumentKey serviceDocKey; WarehouseKey warehouseKey; ReturnMaterialAuthorizationTypeKey rmaTypeKey; CustomerKey customerKey; ShipToAddressKey shipToKey; Policy rmaCreatePolicy; // Create an instance of the service DynamicsGP wsDynamicsGP = new DynamicsGP(); // Be sure the 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 return material authorization object returnMaterialAuthorization = new ReturnMaterialAuthorization(); // Create a service document key object // Populate the Id with a value to uniquely identify the RMA document serviceDocKey = new ServiceDocumentKey(); serviceDocKey.Id = "RMATEST000200"; // Populate the return material authorization object's key property // with the service document key returnMaterialAuthorization.Key = serviceDocKey; // Create a warehouse key object // Populate the Id property to specify the warehouse warehouseKey = new WarehouseKey(); warehouseKey.Id = "WAREHOUSE"; // Populate the return material authorization object's return warehouse // key property returnMaterialAuthorization.ReturnWarehouseKey = warehouseKey; // Create a return material authorization type key object // Populate the Id property to specify the return type rmaTypeKey = new ReturnMaterialAuthorizationTypeKey(); rmaTypeKey.Id = "SVC"; // Populate the return material authorization object's return type key property returnMaterialAuthorization.ReturnTypeKey = rmaTypeKey; // Create a customer key object // Populate the Id to specify the customer customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Populate the return material authorization object's customer key property returnMaterialAuthorization.CustomerKey = customerKey; // Create a ship to key object // Populate the Id property to specify the customer address shipToKey = new ShipToAddressKey(); shipToKey.Id = "PRIMARY"; // Populate the return material authorization object's ship to address key returnMaterialAuthorization.ShipToAddressKey = shipToKey; // Retrieve the create policy for the return material authorization object rmaCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateReturnMaterialAuthorization", context); // Create the new return material authorization document wsDynamicsGP.CreateReturnMaterialAuthorization(returnMaterialAuthorization, context, rmaCreatePolicy); } } }
** Native endpoint **
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; ReturnMaterialAuthorization returnMaterialAuthorization; ServiceDocumentKey serviceDocKey; WarehouseKey warehouseKey; ReturnMaterialAuthorizationTypeKey rmaTypeKey; CustomerKey customerKey; ShipToAddressKey shipToKey; Policy rmaCreatePolicy; // 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 return material authorization object returnMaterialAuthorization = new ReturnMaterialAuthorization(); // Create a service document key object // Populate the Id with a value to uniquely identify the RMA document serviceDocKey = new ServiceDocumentKey(); serviceDocKey.Id = "RMATEST000200"; // Populate the return material authorization object's key property // with the service document key returnMaterialAuthorization.Key = serviceDocKey; // Create a warehouse key object // Populate the Id property to specify the warehouse warehouseKey = new WarehouseKey(); warehouseKey.Id = "WAREHOUSE"; // Populate the return material authorization object's return warehouse // key property returnMaterialAuthorization.ReturnWarehouseKey = warehouseKey; // Create a return material authorization type key object // Populate the Id property to specify the return type rmaTypeKey = new ReturnMaterialAuthorizationTypeKey(); rmaTypeKey.Id = "SVC"; // Populate the return material authorization object's return type key property returnMaterialAuthorization.ReturnTypeKey = rmaTypeKey; // Create a customer key object // Populate the Id to specify the customer customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Populate the return material authorization object's customer key property returnMaterialAuthorization.CustomerKey = customerKey; // Create a ship to key object // Populate the Id property to specify the customer address shipToKey = new ShipToAddressKey(); shipToKey.Id = "PRIMARY"; // Populate the return material authorization object's ship to address key returnMaterialAuthorization.ShipToAddressKey = shipToKey; // Retrieve the create policy for the return material authorization object rmaCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateReturnMaterialAuthorization", context); // Create the new return material authorization document wsDynamicsGP.CreateReturnMaterialAuthorization(returnMaterialAuthorization, context, rmaCreatePolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }