locked
sharing records RRS feed

  • Question

  •  

    Hi ,

     

      

    How can I share a record in a workflow? I saw that we can attribute a record to another user, but I want share.

     

    Thanks

     

    Andrés

    Thursday, December 11, 2008 2:59 PM

Answers

  • Workflow does not have the ability to share records at this time.  You will need to create a customization to automate the record share.

     

    Thursday, December 11, 2008 4:31 PM

All replies

  • Hi Andres,

    You can refer to this article :

    http://msdn.microsoft.com/en-us/library/bb956464.aspx

    Basically you need to utilize GrantAccessRequest.

    Here is the code snippet in how to utilize GrantAccessRequest

            private void ShareCase(ref ICrmService service, string incidentId, string userId)
            {
                try
                {
                    // Create the SecurityPrincipal Object
                    SecurityPrincipal principal = new SecurityPrincipal();
                    principal.Type = SecurityPrincipalType.User;

                    // PrincipalId is the Guid of the user to whom access is being granted
                    principal.PrincipalId = new Guid(userId);

                    // Create the PrincipalAccess Object
                    PrincipalAccess principalAccess = new PrincipalAccess();

                    // Set the PrincipalAccess Object's Properties
                    principalAccess.Principal = principal;

                    // Gives the principal access to read
                    principalAccess.AccessMask = AccessRights.ReadAccess;

                    // Create the Target Object for the Request
                    TargetOwnedIncident target = new TargetOwnedIncident();

                    // EntityId is the Guid of the account access is being granted to
                    target.EntityId = new Guid(incidentId);

                    // Create the Request Object
                    GrantAccessRequest grant = new GrantAccessRequest();

                    // Set the Request Object's properties
                    grant.PrincipalAccess = principalAccess;
                    grant.Target = target;

                    // Execute the Request
                    GrantAccessResponse granted = (GrantAccessResponse)service.Execute(grant);
                }
                catch (SoapException ex)
                {
                    WriteEntryToEventLog("private void ShareCase(ref ICrmService service, string incidentId, string userId)", ex);

                    throw ex;
                }
                catch (Exception e)
                {
                    WriteEntryToEventLog("private void ShareCase(ref ICrmService service, string incidentId, string userId)", e);

                    throw e;
                }
            }

    hope this helps,

    hadi teo.
    haditeo.wordpress.com
    Thursday, December 11, 2008 3:09 PM
  • Workflow does not have the ability to share records at this time.  You will need to create a customization to automate the record share.

     

    Thursday, December 11, 2008 4:31 PM
  • Check this links, there is a solution that you can import and it will allow you to share / unshare records through workflow, for CRM 2001 and CRM 4.0

    http://crm2011sharestep.codeplex.com/releases/view/72393

    http://crm40sharestep.codeplex.com/releases

    Also in this links you can find a little bit more than just share a record in CRM 2011

    http://crm2011workflowutils.codeplex.com/

    Sunday, June 17, 2012 10:13 PM