مشاركة عبر


IOrganizationService.Execute Method (OrganizationRequest)

 

Applies To: Dynamics CRM 2015

Executes a message in the form of a request, and returns a response.

Namespace:   Microsoft.Xrm.Sdk
Assembly:  Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)

Syntax

[FaultContractAttribute(typeof(OrganizationServiceFault))]
[OperationContractAttribute]
OrganizationResponse Execute(
    OrganizationRequest request
)
[FaultContractAttribute((OrganizationServiceFault^::typeid))]
[OperationContractAttribute]
OrganizationResponse^ Execute(
    OrganizationRequest^ request
)
[<FaultContractAttribute(typeof(OrganizationServiceFault))>]
[<OperationContractAttribute>]
abstract Execute : 
        request:OrganizationRequest -> OrganizationResponse
<FaultContractAttribute(GetType(OrganizationServiceFault))>
<OperationContractAttribute>
Function Execute (
    request As OrganizationRequest
) As OrganizationResponse

Parameters

Return Value

Type: Microsoft.Xrm.Sdk.OrganizationResponse

Type: OrganizationResponse
The response from the request. You must cast the return value of this method to the specific instance of the response that corresponds to the Request parameter.

Remarks

Privileges and Access Rights

To execute the message, the caller must have the necessary privileges to the entity type that is specified in the request class. The caller must also have access rights on the specified records in the request class. For more information, see the Request class for the action you want to execute. For example, see AssignRequest.

Notes for Callers

For more information about the exceptions that can be thrown when this method is called, see Handle exceptions in your code.

Method Availability

This method works regardless whether the caller is connected to the server or offline.

Examples

The following example shows how to use the Execute method to assign a queue to a team (early bound). For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. You can find the complete sample in the sample code package in the folder SampleCode\CS\BusinessDataModel\BusinessManagement\AssignRecordToTeam.cs.

The following example shows how to use the Execute method to assign a queue to a team (late bound). For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. You can find the complete sample in the sample code package in the folder SampleCode\CS\GeneralProgramming\LateBound\AssignQueueToTeamDE.cs.


// The queue ID would typically be passed in as an argument or determined by a query.
// The team ID would typically be passed in as an argument or determined by a query.
// Assign the queue to a team.
AssignRequest assignRequest = new AssignRequest()
{
    Assignee = new EntityReference
    {
        LogicalName = "team",
        Id = _teamId
    },

    Target = new EntityReference("queue", _queueId)
};

_service.Execute(assignRequest);

' The queue ID would typically be passed in as an argument or determined by a query.
' The team ID would typically be passed in as an argument or determined by a query.
' Assign the queue to a team.
Dim assignRequest As New AssignRequest() With {.Assignee = New EntityReference With { _
        .LogicalName = "team", .Id = _teamId}, .Target = New EntityReference("queue", _queueId)}

_service.Execute(assignRequest)

See Also

IOrganizationService Interface
Microsoft.Xrm.Sdk Namespace
Use messages (request and response classes) with the Execute method
The security model of Microsoft Dynamics CRM
Privileges by message
Privileges by entity
Handle exceptions in your code
Troubleshooting and error handling

Return to top

© 2016 Microsoft. All rights reserved. Copyright