This documentation is archived and is not being maintained.

Assign Message (CrmService)

Dynamics
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online only

Assigns the specified entity instance to a new security principal (user). This changes the ownerid attribute of the instance.

The relevant classes are specified in the following table.

TypeClass
RequestAssignRequest
ResponseAssignResponse
Target base classTargetOwned Class
Optional ParametersRequestIdOptionalParameter
EntitySee below.

The following table shows the entities and target classes for this message.

EntityTarget class
accountTargetOwnedAccount
annotationTargetOwnedAnnotation
appointmentTargetOwnedAppointment
asyncoperationTargetOwnedAsyncOperation
campaignactivityTargetOwnedCampaignActivity
campaignresponseTargetOwnedCampaignResponse
campaignTargetOwnedCampaign
contactTargetOwnedContact
contractTargetOwnedContract
customeropportunityroleTargetOwnedCustomerOpportunityRole
customerrelationshipTargetOwnedCustomerRelationship
duplicateruleTargetOwnedDuplicateRule
DynamicEntityTargetOwnedDynamic
emailTargetOwnedEmail
faxTargetOwnedFax
incidentresolutionTargetOwnedIncidentResolution
invoiceTargetOwnedInvoice
leadTargetOwnedLead
letterTargetOwnedLetter
listTargetOwnedList
mailmergetemplateTargetOwnedMailMergeTemplate
opportunityTargetOwnedOpportunity
opportunitycloseTargetOwnedOpportunityClose
ordercloseTargetOwnedOrderClose
phonecallTargetOwnedPhoneCall
quoteTargetOwnedQuote
quotecloseTargetOwnedQuoteClose
reportTargetOwnedReport
salesorderTargetOwnedSalesOrder
serviceappointmentTargetOwnedServiceAppointment
taskTargetOwnedTask
templateTargetOwnedTemplate
User-owned custom entityTargetOwnedX where X is the name of the custom entity.
userqueryTargetOwnedUserQuery
workflowTargetOwnedWorkflow

Remarks

To use this message, pass an instance of the AssignRequest class as the request parameter in the Execute method.

This action applies to the parent object and associated objects that have the same owner as the parent object. Therefore, when you assign the parent object to a new owner, only the associated objects that have the same owner as the parent object are assigned.

If the value of the organization.sharetopreviousowneronassign property is true, when an object is assigned to a new owner, it is shared with the previous owner with full rights. In this case, either the new owner or the previous owner can remove the relationship or lower the level of privileges the previous owner had on the object.

For a description of how actions on a parent instance affect child instances, see Cascading Rules.

To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see Assign Privileges.

Note    Incidents cannot be assigned to another user with this message. Ownership of an incident can be changed using the Route message.

Important  For activity entities, when registering a plug-in for an Assign message, also register the plug-in for a Route message. The Microsoft Dynamics CRM Web application uses the Route message when assigning activities. Registering a plug-in for both messages ensures that the plug-in is executed regardless of how the activity assign was initiated: from the Web application or from an SDK Request.

Example

The following code example demonstrates how to assign the specified entity instance to a new security principal (user).

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the SecurityPrincipal object.
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;

// PrincipalId is some known Guid belonging to the user or team that will own this record.
assignee.PrincipalId = new Guid("326A0053-71CB-465E-9BEB-633E2E0851A9");

// Create the target object for the request.
TargetOwnedAccount target = new TargetOwnedAccount();

// Set the properties of the target object.
// EntityId is some known Guid belonging to the account that is being assigned to the user.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
AssignRequest assign = new AssignRequest();

// Set the properties of the request object.
assign.Assignee = assignee;
assign.Target = target;
      
// Execute the request.
AssignResponse assignResponse = (AssignResponse)service.Execute(assign);
[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the SecurityPrincipal object.
Dim assignee As New SecurityPrincipal
assignee.Type = SecurityPrincipalType.User

' PrincipalId is some known Guid belonging to the user or team that will own this record.
assignee.PrincipalId = New Guid("326A0053-71CB-465E-9BEB-633E2E0851A9");

' Create the target object for the request.
Dim target As New TargetOwnedAccount()

' Set the properties of the target object.
' EntityId is some known Guid belonging to the account that is being assigned to the user.
target.EntityId = New Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

' Create the request object.
Dim assign As New AssignRequest()

' Set the properties of the request object.
assign.Assignee = assignee
assign.Target = target

' Execute the request.
Dim assignResponse As AssignResponse = CType(service.Execute(assign), AssignResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: