SetStateRequest Class
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)
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 | |
appointment | Both | |
businessunit | Server | |
campaign | Both | |
campaignactivity | Both | |
campaignresponse | Both | |
connection | Both | |
connectionrole | Both | |
contact | Both | |
contract | Both | |
contractdetail | Both | ContractDetail (Contract Line) Entity OptionSet Attribute Metadata |
discounttype | Both | DiscountType (Discount List) Entity OptionSet Attribute Metadata |
Both | ||
fax | Both | |
goal | Server | |
goalrollupquery | Server | |
importmap | Both | |
incident | Both | |
incidentresolution | Both | IncidentResolution (Case Resolution) Entity OptionSet Attribute Metadata |
invoice | Both | |
kbarticle | Both | |
lead | Both | |
letter | Both | |
list | Both | |
mailmergetemplate | Both | |
metric | Server | |
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 | |
opportunityclose | Both | OpportunityClose Activity Entity OptionSet Attribute Metadata |
orderclose | Both | |
phonecall | Both | |
pricelevel | Both | |
processsession | Both | ProcessSession (Dialog Session) Entity OptionSet Attribute Metadata |
product | Both | |
queue | Both | |
queueitem | Both | |
quote | Both | |
quoteclose | Both | |
recurringappointmentmaster | Both | RecurringAppointmentMaster Entity OptionSet Attribute Metadata |
relationshiprole | Both | |
salesorder | Both | |
savedquery | Server | |
sdkmessageprocessingstep | Server | SdkMessageProcessingStep Entity OptionSet Attribute Metadata |
serviceappointment | Both | |
sharepointdocumentlocation | Both | SharePointDocumentLocation Entity OptionSet Attribute Metadata |
sharepointsite | Both | |
systemuser | Server | |
task | Both | |
transactioncurrency | Server | TransactionCurrency (Currency) Entity OptionSet Attribute Metadata |
uomschedule | Both | UoMSchedule (Unit Group) Entity OptionSet Attribute Metadata |
userquery | Both | |
workflow | Server |
Development Platforms
Windows Server 2008Target Platforms
Windows Server 2008, Windows 7 (All Versions), Windows Vista (All Versions)Reference
SetStateRequest MembersMicrosoft.Crm.Sdk.Messages Namespace
SetStateResponse
Other Resources
SetState PrivilegesSample: Validate Record State and Set State of the Record
How Role-Based Security Can Be Used to Control Access to Entities In CRM
How Instance-Based Security Can Be Used to Control Access to Entity Instances (Records) In CRM
Send comments about this topic to Microsoft.
© 2011 Microsoft Corporation. All rights reserved.