CreditLimit


Description

Provides the underlying storage for instances of concrete customer credit limit and vendor credit limit types that derive from it.

Properties

Property

Type

Length

Default

Description

Item

Choice

N/A

N/A

A choice type that contains either a MoneyAmount or a CreditLimitSpecialAmount.


Examples

The following C# example demonstrates how to retrieve the Item property of a credit limit object and determine whether it is a money amount or a credit limit special amount. Note how the GetType() function is used to retrieve the underlying type of the Item property, and how the typeof() function is used to retrieve the types for the comparison operation.

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;
			Customer customer;
			CustomerKey customerKey;
			CustomerCreditLimit creditLimit;
			MoneyAmount creditLimitAmount;
			CreditLimitSpecialAmount creditLimitSpecialAmount;

			// Create an instance of the web service
			DynamicsGP wsDynamicsGP = new DynamicsGP();

			// Be sure that default credentials are being used
			wsDynamicsGP.UseDefaultCredentials = true;

			// Create a context with which to call the web service
			context = new Context();

			// Specify which company (lesson company)
			companyKey = new DynamicsGPService.CompanyKey();
			companyKey.Id = (-1);

			// Set up the context
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Create a customer key
			customerKey = new CustomerKey();
			customerKey.Id = "AARONFIT0001";

			// Retrieve the customer object
			customer = wsDynamicsGP.GetCustomerByKey(customerKey, context);

			// Examine the credit limit information
			creditLimit = new CustomerCreditLimit();
			creditLimit = customer.CreditLimit;

			if (creditLimit.Item.GetType() == typeof(MoneyAmount))
			{
				creditLimitAmount = (MoneyAmount)creditLimit.Item;
				MessageBox.Show("Credit limit is a money amount of: " + creditLimitAmount.Value.ToString());
		}

			if (creditLimit.Item.GetType() == typeof(CreditLimitSpecialAmount))
			{
				creditLimitSpecialAmount = (CreditLimitSpecialAmount)creditLimit.Item;
				MessageBox.Show("Credit limit is special amount: " + creditLimitSpecialAmount.ToString());
		}
	}
}
}

The following C# example shows how the Item property for a customer credit limit can be set to one of the values in the CreditLimitSpecialAmount enumeration. Notice how the Item property is cast to be of the proper type.

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;
			Customer customer;
			CustomerKey customerKey;
			CustomerCreditLimit creditLimit;
			Policy customerUpdatePolicy;

			// Create an instance of the web service
			DynamicsGP wsDynamicsGP = new DynamicsGP();

			// Be sure that default credentials are being used
			wsDynamicsGP.UseDefaultCredentials = true;

			// Create a context with which to call the web service
			context = new Context();

			// Specify which company (lesson company)
			companyKey = new DynamicsGPService.CompanyKey();
			companyKey.Id = (-1);

			// Set up the context
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Get the UpdateCustomer policy
			customerUpdatePolicy = wsDynamicsGP.GetPolicyByOperation("UpdateCustomer", context);

			// Create a customer key
			customerKey = new CustomerKey();
			customerKey.Id = "ADVANCED0001";

			// Create the customer object
			customer = new Customer();
			customer.Key = customerKey;

			// Set the credit limit information
			creditLimit = new CustomerCreditLimit();
			creditLimit.Item = (CreditLimitSpecialAmount)CreditLimitSpecialAmount.NoCredit;
			customer.CreditLimit = creditLimit;

			// Update the customer
			wsDynamicsGP.UpdateCustomer(customer, context, customerUpdatePolicy);
	}
}
}


Documentation Feedback