Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Description
This method creates a new service equipment document.
Parameters
Parameter |
Type |
Description |
|---|---|---|
serviceEquipment |
The service equipment 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 service equipment document with the key value "SETEST000100". The required Key, CustomerKey, and AddressKey properties are populated. All other properties use default values.
** 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;
ServiceEquipment serviceEquipment;
ItemKey itemKey;
ServiceEquipmentKey servEquipKey;
CustomerKey customerKey;
AddressKey addressKey;
Policy serviceEquipmentCreatePolicy;
// 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 new service equipment object
serviceEquipment = new ServiceEquipment();
// Create an item key object and specify the item
itemKey = new ItemKey();
itemKey.Id = "1-A3261A";
// Create a service equipment key object
// Populate the Id property with a value that uniquely identifies the document
// Populate the ItemKey property with the item key object
servEquipKey = new ServiceEquipmentKey();
servEquipKey.Id = "SETEST000100";
servEquipKey.ItemKey = itemKey;
// Populate the service equipment object's Key property with the service equipment key object
serviceEquipment.Key = servEquipKey;
// Create a customer key object
// Populate the Id property to specify the customer
customerKey = new CustomerKey();
customerKey.Id = "AARONFIT0001";
// Populate the service equipment object's CustomerKey property with the customer key object
serviceEquipment.CustomerKey = customerKey;
// Create an address key object
// Populate teh address key object's Id to specify the customer address information
addressKey = new AddressKey();
addressKey.Id = "PRIMARY";
// Populate the service equipment object's AddressKey property with the address key object
serviceEquipment.AddressKey = addressKey;
// Get the create policy for service equipment
serviceEquipmentCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateServiceEquipment",
context);
// Create the service equipment document
wsDynamicsGP.CreateServiceEquipment(serviceEquipment, context, serviceEquipmentCreatePolicy);
}
}
}
** 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;
ServiceEquipment serviceEquipment;
ItemKey itemKey;
ServiceEquipmentKey servEquipKey;
CustomerKey customerKey;
AddressKey addressKey;
Policy serviceEquipmentCreatePolicy;
// 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 new service equipment object
serviceEquipment = new ServiceEquipment();
// Create an item key object and specify the item
itemKey = new ItemKey();
itemKey.Id = "1-A3261A";
// Create a service equipment key object
// Populate the Id property with a value that uniquely identifies the document
// Populate the ItemKey property with the item key object
servEquipKey = new ServiceEquipmentKey();
servEquipKey.Id = "SETEST000100";
servEquipKey.ItemKey = itemKey;
// Populate the service equipment object's Key property with the service equipment key object
serviceEquipment.Key = servEquipKey;
// Create a customer key object
// Populate the Id property to specify the customer
customerKey = new CustomerKey();
customerKey.Id = "AARONFIT0001";
// Populate the service equipment object's CustomerKey property with the customer key object
serviceEquipment.CustomerKey = customerKey;
// Create an address key object
// Populate teh address key object's Id to specify the customer address information
addressKey = new AddressKey();
addressKey.Id = "PRIMARY";
// Populate the service equipment object's AddressKey property with the address key object
serviceEquipment.AddressKey = addressKey;
// Get the create policy for service equipment
serviceEquipmentCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateServiceEquipment",
context);
// Create the service equipment document
wsDynamicsGP.CreateServiceEquipment(serviceEquipment, context, serviceEquipmentCreatePolicy);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}