Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to use the Microsoft Dynamics CRM 3.0 SDK to programmatically release a contract that was put on hold in Microsoft Dynamics CRM 3.0


View products that this article applies to.

Introduction

This article describes how to use the Microsoft Dynamics CRM 3.0 Software Development Kit (SDK) to programmatically release a contract that was put on hold in Microsoft Dynamics CRM 3.0.

↑ Back to the top


More information

To programmatically release a contract that was put on hold in Microsoft Dynamics CRM 3.0, you must take advantage of the Microsoft Dynamics CRM Web service and its Execute message. Before you can release a contract that was put on hold, you must change the state of the contract. The Microsoft Dynamics CRM 3.0 SDK contains information about the SetStateContract message to help you change the state of a contract. You can specify the new state, and you can provide a status reason that accompanies this new state.

When you use the Microsoft Dynamics CRM 3.0 SDK to programmatically release a contract, you must set the state of the contract to Invoiced instead of Active. Microsoft Dynamics CRM disallows you to change a contract's state from OnHold to Active. If you try to change a contract's state from OnHold to Active, you receive the following error message if your code encounters a SOAPException exception:
The target state is invalid. The target state may not exist or the system does not allow changing to the target state from the current state. Please check the documentation on this state change request. ErrorCode: -2147220970.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide extra functionality or construct procedures to meet your specific requirements.

The following code example illustrates how to programmatically release a contract that was put on hold in Microsoft Dynamics CRM 3.0.
try
{
	CrmService service = new CrmService();
	service.Credentials=System.Net.CredentialCache.DefaultCredentials;

	SetStateContractRequest change = new SetStateContractRequest();
	change.ContractState = ContractState.Active;
	change.ContractStatus=-1;
	
	//Set EntityId to GUID of the contract being released.
	change.EntityId=new Guid("ED90535A-4FA6-DB11-B75B-000874DE7397");
				
	SetStateContractResponse changed = (SetStateContractResponse)service.Execute(change);

           Console.WriteLine("Changed status successfully.");

}
catch (System.Web.Services.Protocols.SoapException err)
{
	MessageBox.Show(err.Detail.OuterXml.ToString());
}

↑ Back to the top


References

For more information about the SetStateContract class, see the SetStateContract class topic in the Microsoft Dynamics CRM 3.0 SDK. To view the SetStateContract class topic, visit the following Microsoft Web site: To download the Microsoft Dynamics CRM 3.0 SDK, visit the following Microsoft Web site:

↑ Back to the top


Keywords: KB932477, kbmbsmigrate, kbhowto

↑ Back to the top

Article Info
Article ID : 932477
Revision : 5
Created on : 8/21/2007
Published on : 8/21/2007
Exists online : False
Views : 419