Export (0) Print
Expand All

SetStateRequest Class

Dynamics CRM 2013

Applies To: Microsoft Dynamics CRM 2013, Microsoft Dynamics CRM Online

Contains the data that is needed to set the state of an entity record.

Namespace: Microsoft.Crm.Sdk.Messages
Assembly: Microsoft.Crm.Sdk.Proxy (in Microsoft.Crm.Sdk.Proxy.dll)

'Declaration
<DataContractAttribute(Namespace:="http://schemas.microsoft.com/crm/2011/Contracts")> _
Public NotInheritable Class SetStateRequest
	Inherits OrganizationRequest

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.


// Create the Request Object
SetStateRequest state = new SetStateRequest();

// Set the Request Object's Properties
state.State = new OptionSetValue((int)IncidentState.Active);
state.Status = 
    new OptionSetValue((int)incident_statuscode.WaitingforDetails);

// Point the Request to the case whose state is being changed
state.EntityMoniker = caseReference;

// Execute the Request
SetStateResponse stateSet = (SetStateResponse)_serviceProxy.Execute(state);

// Check if the state was successfully set
Incident incident = _serviceProxy.Retrieve(Incident.EntityLogicalName, 
    _caseIncidentId, new ColumnSet(allColumns: true)).ToEntity<Incident>();

if (incident.StatusCode.Value == (int)incident_statuscode.WaitingforDetails)
{
    Console.WriteLine("Record state set successfully.");
}
else
{
    Console.WriteLine("The request to set the record state failed.");
}

Message Availability

This message works regardless whether the caller is connected to the server or offline. Not all entity types support this message offline. See Supported Entities later in this topic.

Usage

Pass an instance of this class to the Execute method, which returns an instance of the SetStateResponse class.

Privileges and Access Rights

To perform this action, the caller must have privileges on the specified entity in the EntityMoniker property.

For a complete list of the required privileges, see SetState Privileges.

Valid State and Status value combinations

The valid combinations of state and status code values varies for many entities. See Default status and status reason values for a list of default values for specific system entities.

For a list of the state and status values valid for custom entities in your organization, refer to the entity metadata.

To view the entity metadata for your organization, install the Metadata Browser solution described in Browse the Metadata for Your Organization. You can also view the metadata for an uncustomized organization in the Excel file called EntityMetadata.xlsx included in the tools folder of the SDK download.

Supported Entities

The following table shows the default entities that support this message and whether the message is available when the caller is connected to the server (Server), disconnected from the server (Offline) or both (Both).

Entity Availability

account

Both

appointment

Both

businessunit

Server

campaign

Both

campaignactivity

Both

campaignresponse

Both

connection

Both

connectionrole

Both

contact

Both

contract

Both

contractdetail

Both

discounttype

Both

email

Both

emailserverprofile

Server

fax

Both

goal

Server

goalrollupquery

Server

importmap

Both

incident

Both

incidentresolution

Both

invoice

Both

kbarticle

Both

lead

Both

letter

Both

list

Both

mailbox

Server

mailmergetemplate

Both

metric

Server

msdyn_postalbum

Server

msdyn_postconfig

Server

msdyn_postruleconfig

Server

opportunity

Both

opportunityclose

Both

orderclose

Both

phonecall

Both

pricelevel

Both

processsession

Both

product

Both

queue

Both

queueitem

Both

quote

Both

quoteclose

Both

recurringappointmentmaster

Both

relationshiprole

Both

salesorder

Both

savedquery

Server

sdkmessageprocessingstep

Server

serviceappointment

Both

sharepointdocumentlocation

Both

sharepointsite

Both

systemuser

Server

task

Both

transactioncurrency

Server

uomschedule

Both

userquery

Both

workflow

Server


System.Object
   Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Crm.Sdk.Messages.SetStateRequest

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Server 2008, Windows Server 2012, Windows 7 (All Versions), Windows 8 (All Versions)

Target Platforms

Windows Server 2008, ,Windows Server 2012, ,Windows 7 (All Versions),

Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.

Community Additions

ADD
Show:
© 2014 Microsoft