UpdateServiceEquipment


Description

Updates the specified service equipment object, storing the current values in the database.

Parameters

Parameter

Type

Description

serviceEquipment

ServiceEquipment

The service equipment object that is being updated.

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

 

Examples

The following C# example retrieves the service equipment document with the service document Id of “00045478” and item key of “2-A3284A“. The example updates the service equipment document’s TechnicianKey property to “T0117”. The UpdateServiceEquipment operation saves the newly assigned technician Id and the service equipment object’s other 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;
			ItemKey itemKey;
			ServiceEquipmentKey serviceEquipmentKey;
			ServiceEquipment serviceEquipment;
			Policy serviceEquipUpdatePolicy;

			// 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);

			// Create a technician key and specify the technician for the service equipment object
			ServiceTechnicianKey technicianKey = new ServiceTechnicianKey();
			technicianKey.Id = "T0117";

			// Add the technician key to the service equipment object
			serviceEquipment.TechnicianKey = technicianKey;

			// Get the update policy for service equipment
			serviceEquipUpdatePolicy = wsDynamicsGP.GetPolicyByOperation("UpdateServiceEquipment", context);

			// Update the service equipment information
			wsDynamicsGP.UpdateServiceEquipment(serviceEquipment, context, serviceEquipUpdatePolicy);
	}
}
}

 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;
			ItemKey itemKey;
			ServiceEquipmentKey serviceEquipmentKey;
			ServiceEquipment serviceEquipment;
			Policy serviceEquipUpdatePolicy;

			// 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);

			// Create a technician key and specify the technician for the service equipment object
			ServiceTechnicianKey technicianKey = new ServiceTechnicianKey();
			technicianKey.Id = "T0117";

			// Add the technician key to the service equipment object
			serviceEquipment.TechnicianKey = technicianKey;

			// Get the update policy for service equipment
			serviceEquipUpdatePolicy = wsDynamicsGP.GetPolicyByOperation("UpdateServiceEquipment", context);

			// Update the service equipment information
			wsDynamicsGP.UpdateServiceEquipment(serviceEquipment, context, serviceEquipUpdatePolicy);

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


Documentation Feedback