How to share a record in MS Dynamics CRM using workflow
Asked Answered
M

4

3

I would like to do the following:

when a Sales person assigns a custom entity (let's call it 'Primary Expertise') to an Opportunity in MS CRM 4.0, the system would share the Opportunity with the user that is defined as the Owner of the associated 'Primary Expertise' record.

I would like to do it automatically via workflow but cannot find the workflow step that would accomplish that. Yes, and I read on some forums that it's actually not possible yet, only via a .NET assembly.

Experience, anyone?

Movie answered 24/11, 2008 at 13:50 Comment(0)
A
3

Correct, it is only possible via .NET assembly. However you could (If you using CRM 4) have the workflow change the owner to the owner of the activity and use the share with previous owner option to enable the old owner access to your custom entity?

Arborescent answered 12/1, 2009 at 15:49 Comment(0)
O
4

Try this:

http://crm40sharestep.codeplex.com

Obelize answered 14/5, 2009 at 1:2 Comment(0)
A
3

Correct, it is only possible via .NET assembly. However you could (If you using CRM 4) have the workflow change the owner to the owner of the activity and use the share with previous owner option to enable the old owner access to your custom entity?

Arborescent answered 12/1, 2009 at 15:49 Comment(0)
S
3

It is possible only by invoking custom workflow activity. Inside the custom workflow activity, you can invoke GrantAccessRequest and GrantAccessResponse by configuring the PrincipalAccess object.

Please refer to this "Sharing Object" section for details.

Sabina answered 1/7, 2009 at 13:19 Comment(0)
J
3

If you'll decide to go with custom plugin, your code might look like this:

var rights = AccessRights.ReadAccess | AccessRights.WriteAccess;

var principalAccess = new PrincipalAccess
{
    // Gives the principal read write access
    AccessMask = rights,

    // Set the PrincipalAccess Object's Properties
    Principal = sharingTarget.Key
};

// Create the Request Object
var grantAcessRequest = new GrantAccessRequest();
// Set the Request Object's properties
grantAcessRequest.PrincipalAccess = principalAccess;
// Set the Target. In my case it is account record
var entityReference = new EntityReference(localContext.PluginExecutionContext.PrimaryEntityName,
                                          localContext.PluginExecutionContext.PrimaryEntityId);
//throw new InvalidPluginExecutionException("EntityReference");
grantAcessRequest.Target = entityReference;

// Execute the Request
localContext.OrganizationService.Execute(grantAcessRequest);
Jerrodjerrol answered 16/4, 2013 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.