Hi,
I am trying to write the plugin code in dynamic CRM 2016 on-premise for when record is created then automatically record should be assigned to specific user and campaign. so can any one help me.
*This post is locked for comments
Hi,
either the user checks every time his "my record" view
or you create a workflow which create a task activity saying that he needs t review the corresponding record because it was assigned to him.
He will become owner, From Views user can see the records.
Hemant
Ok. How user knows about assigned records?
Hi Indrasena,
Please go through this..
// Create the Request Object and Set the Request Object's Properties
AssignRequest assign = new AssignRequest
{
Assignee = new EntityReference(SystemUser.EntityLogicalName,
_otherUserId),
Target = new EntityReference(Account.EntityLogicalName,
_accountId)
};
https://ssharmacrm.wordpress.com/2016/05/03/how-to-assign-a-record-to-a-new-owner/
msdn.microsoft.com/.../gg309540.aspx
Hemant
Hello,
In additional to that here is one sample from CRM SDK
msdn.microsoft.com/.../gg309540.aspx
Thanks
I am not sure what you mean to assign to campaign, as campaigns use marketing lists.
Regarding assigning the ownership of a record to a particular entity you can use the following code:
/// <summary>
/// Changes the Ownership of a record
/// </summary>
/// <param name="entityname">The name of the entity that is being assigned to</param>
/// <param name="id">The Guid of the entity record that is being assigned to</param>
/// <param name="ownerid">The user unique id that is becoming the assignee</param>
public void AssignOwnership(string entityname, Guid id, Guid ownerid)
{
AssignRequest request = new AssignRequest();
request.Target = new EntityReference(entityname, id);
request.Assignee = new EntityReference("systemuser", ownerid);
try
{
AssignResponse response = (AssignResponse)service.Execute(request);
}
catch (FaultException<OrganizationServiceFault> ex)
{
tracingService.Trace("Error Assigning Record: {0}", ex.Message);
throw new InvalidPluginExecutionException(ex.Message);
}
}
To call the function your basically specify the entity name, entity id and user id
If you use the LocalPluginContext for example, you can set it like this:
string entityName = localContext.PluginExecutionContext.PrimaryEntityName;
Guid entityId = localContext.PluginExecutionContext.PrimaryEntityId;
Guid userId = localContext.PluginExecutionContext.UserId;
AssignOwnership(entityName, entityId, userId);
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156