GetServiceEquipmentByKey

Forefront

Description

Retrieves a single service equipment object based on the specified service equipment key.

Parameters

Parameter

Type

Description

key

ServiceEquipmentKey

The service equipment key object that specifies the service equipment to retrieve. The service equipment key requires an item key and service equipment Id.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetServiceEquipmentByKeyResult

ServiceEquipment

A service call object.


Interfaces

  • Dynamics GP
  • Field Service

Examples

The following C# example retrieves a service equipment object with the service equipment key value "00045478" and an item key with an Id of "2-A3284A". A message box displays the service equipment customer Id and status.

Cc508673.LegacyEndpoint(en-us,MSDN.10).gif Legacy endpoint

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            ItemKey itemKey;
            ServiceEquipmentKey serviceEquipmentKey;
            ServiceEquipment serviceEquipment;

            // 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 an item key object
            itemKey = new ItemKey();
            itemKey.Id = "2-A3284A";

            // Create a service equipment key object
            serviceEquipmentKey = new ServiceEquipmentKey();
            serviceEquipmentKey.Id = "00045478";
            serviceEquipmentKey.ItemKey = itemKey;

            // Retrieve the specified service equipment object
            serviceEquipment = wsDynamicsGP.GetServiceEquipmentByKey(serviceEquipmentKey, context);

            // Display the service equipment description
            MessageBox.Show("Customer: " + serviceEquipment.CustomerKey.Id +
                "  Status: " + serviceEquipment.StatusKey.Id);
        }
    }
}

Cc508673.NativeEndpoint(en-us,MSDN.10).gif Native endpoint 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            ItemKey itemKey;
            ServiceEquipmentKey serviceEquipmentKey;
            ServiceEquipment serviceEquipment;

            // 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 an item key object
            itemKey = new ItemKey();
            itemKey.Id = "2-A3284A";

            // Create a service equipment key object
            serviceEquipmentKey = new ServiceEquipmentKey();
            serviceEquipmentKey.Id = "00045478";
            serviceEquipmentKey.ItemKey = itemKey;

            // Retrieve the specified service equipment object
            serviceEquipment = wsDynamicsGP.GetServiceEquipmentByKey(serviceEquipmentKey, context);

            // Display the service equipment description
            MessageBox.Show("Customer: " + serviceEquipment.CustomerKey.Id +
                "  Status: " + serviceEquipment.StatusKey.Id);

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