Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SetStateRequest Class

[Applies to: Microsoft Dynamics CRM 2011]

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)
'Usage

[DataContractAttribute(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")] 
public sealed class SetStateRequest : 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.

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). The table also includes a link to the topic that contains the values for the statecode attribute for each entity

Entity Availability State values

account

Both

Account Entity OptionSet Attribute Metadata

appointment

Both

Appointment Entity OptionSet Attribute Metadata

businessunit

Server

BusinessUnit Entity OptionSet Attribute Metadata

campaign

Both

Campaign Entity OptionSet Attribute Metadata

campaignactivity

Both

Campaign Entity OptionSet Attribute Metadata

campaignresponse

Both

CampaignResponse Entity OptionSet Attribute Metadata

connection

Both

Connection Entity OptionSet Attribute Metadata

connectionrole

Both

ConnectionRole Entity OptionSet Attribute Metadata

contact

Both

Contact Entity OptionSet Attribute Metadata

contract

Both

Contract Entity OptionSet Attribute Metadata

contractdetail

Both

ContractDetail (Contract Line) Entity OptionSet Attribute Metadata

discounttype

Both

DiscountType (Discount List) Entity OptionSet Attribute Metadata

email

Both

Email (E-mail) Entity OptionSet Attribute Metadata

fax

Both

Fax Entity OptionSet Attribute Metadata

goal

Server

Goal Entity OptionSet Attribute Metadata

goalrollupquery

Server

GoalRollupQuery Entity OptionSet Attribute Metadata

importmap

Both

ImportMap (Data Map) Entity OptionSet Attribute Metadata

incident

Both

Incident (Case) Entity OptionSet Attribute Metadata

incidentresolution

Both

IncidentResolution (Case Resolution) Entity OptionSet Attribute Metadata

invoice

Both

Invoice Entity OptionSet Attribute Metadata

kbarticle

Both

KbArticle (Article) Entity OptionSet Attribute Metadata

lead

Both

Lead Entity OptionSet Attribute Metadata

letter

Both

Letter Entity OptionSet Attribute Metadata

list

Both

List (Marketing List) Entity OptionSet Attribute Metadata

mailmergetemplate

Both

MailMergeTemplate Entity OptionSet Attribute Metadata

metric

Server

Metric (Goal Metric) Entity OptionSet Attribute Metadata

msdyn_postalbum

Server

msdyn_PostAlbum (Profile Album) Entity OptionSet Attribute Metadata

msdyn_postconfig

Server

msdyn_PostConfig (Post Configuration) Entity OptionSet Attribute Metadata

msdyn_postruleconfig

Server

msdyn_PostRuleConfig (Post Rule Configuration) Entity OptionSet Attribute Metadata

opportunity

Both

Opportunity Entity OptionSet Attribute Metadata

opportunityclose

Both

OpportunityClose Activity Entity OptionSet Attribute Metadata

orderclose

Both

OrderClose Activity Entity OptionSet Attribute Metadata

phonecall

Both

PhoneCall Entity OptionSet Attribute Metadata

pricelevel

Both

PriceLevel (PriceList) Entity OptionSet Attribute Metadata

processsession

Both

ProcessSession (Dialog Session) Entity OptionSet Attribute Metadata

product

Both

Product Entity OptionSet Attribute Metadata

queue

Both

Queue Entity OptionSet Attribute Metadata

queueitem

Both

QueueItem Entity OptionSet Attribute Metadata

quote

Both

Quote Entity OptionSet Attribute Metadata

quoteclose

Both

QuoteClose Activity Entity OptionSet Attribute Metadata

recurringappointmentmaster

Both

RecurringAppointmentMaster Entity OptionSet Attribute Metadata

relationshiprole

Both

RelationshipRole Entity OptionSet Attribute Metadata

salesorder

Both

SalesOrder (Order) Entity OptionSet Attribute Metadata

savedquery

Server

SavedQuery (View) Entity OptionSet Attribute Metadata

sdkmessageprocessingstep

Server

SdkMessageProcessingStep Entity OptionSet Attribute Metadata

serviceappointment

Both

ServiceAppointment Entity OptionSet Attribute Metadata

sharepointdocumentlocation

Both

SharePointDocumentLocation Entity OptionSet Attribute Metadata

sharepointsite

Both

SharePointSite Entity OptionSet Attribute Metadata

systemuser

Server

SystemUser (User) Entity OptionSet Attribute Metadata

task

Both

Task Entity OptionSet Attribute Metadata

transactioncurrency

Server

TransactionCurrency (Currency) Entity OptionSet Attribute Metadata

uomschedule

Both

UoMSchedule (Unit Group) Entity OptionSet Attribute Metadata

userquery

Both

UserQuery (Saved View) Entity OptionSet Attribute Metadata

workflow

Server

Workflow (Process) Entity OptionSet Attribute Metadata


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

Target Platforms

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

Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.