Share via


CreateServiceQuote

Description

This method creates a new service quote document.

Parameters

Parameter

Type

Description

serviceQuote

ServiceQuote

The service quote object being created.

context

Context

Specifies information about how the method will be called.

policy

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 service quote document with the key value "SQTEST0100". The required Key, CustomerKey, and ShipToAddressKey properties are populated. All other properties use default values.

Cc508676.LegacyEndpoint(en-us,MSDN.10).gif** 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;
            ServiceQuote serviceQuote;
            ServiceDocumentKey serviceDocKey;
            CustomerKey customerKey;
            ShipToAddressKey shipToAddressKey;
            Policy serviceQuoteCreatePolicy;

            // 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 service quote object
            serviceQuote = new ServiceQuote();

            // Create a service document key object
            // Populate the Id property with a value that uniquely identifies the service quote
            serviceDocKey = new ServiceDocumentKey();
            serviceDocKey.Id = "SQTEST0100";

            // Populate the service quote object's Key property with the service document key object
            serviceQuote.Key = serviceDocKey;

            // Create a customer key object
            // Populate the Id property to specify the customer
            customerKey = new CustomerKey();
            customerKey.Id = "AARONFIT0001";

            // Populate the service quote object's CustomerKey property with the customer
            // key object
            serviceQuote.CustomerKey = customerKey;

            // Create a ship to address key object
            // Populate the Id to specify the customer address for the service quote
            shipToAddressKey = new ShipToAddressKey();
            shipToAddressKey.Id = "PRIMARY";

            // Populate the service quote object's ship to address key property
            serviceQuote.ShipToAddressKey = shipToAddressKey;

            // Get the create policy for service quotes
            serviceQuoteCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateServiceQuote", context);

            // Create the service quote
            wsDynamicsGP.CreateServiceQuote(serviceQuote, context, serviceQuoteCreatePolicy);
        }
    }
}

Cc508676.NativeEndpoint(en-us,MSDN.10).gif** 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;
            ServiceQuote serviceQuote;
            ServiceDocumentKey serviceDocKey;
            CustomerKey customerKey;
            ShipToAddressKey shipToAddressKey;
            Policy serviceQuoteCreatePolicy;

            // 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 service quote object
            serviceQuote = new ServiceQuote();

            // Create a service document key object
            // Populate the Id property with a value that uniquely identifies the service quote
            serviceDocKey = new ServiceDocumentKey();
            serviceDocKey.Id = "SQTEST0100";

            // Populate the service quote object's Key property with the service document key object
            serviceQuote.Key = serviceDocKey;

            // Create a customer key object
            // Populate the Id property to specify the customer
            customerKey = new CustomerKey();
            customerKey.Id = "AARONFIT0001";

            // Populate the service quote object's CustomerKey property with the customer
            // key object
            serviceQuote.CustomerKey = customerKey;

            // Create a ship to address key object
            // Populate the Id to specify the customer address for the service quote
            shipToAddressKey = new ShipToAddressKey();
            shipToAddressKey.Id = "PRIMARY";

            // Populate the service quote object's ship to address key property
            serviceQuote.ShipToAddressKey = shipToAddressKey;

            // Get the create policy for service quotes
            serviceQuoteCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateServiceQuote", context);

            // Create the service quote
            wsDynamicsGP.CreateServiceQuote(serviceQuote, context, serviceQuoteCreatePolicy);

            // Close the service
            if(wsDynamicsGP.State != CommunicationState.Faulted)
            {
                wsDynamicsGP.Close();
            }
        }
    }
}