locked
How to fetch all users for a specific Security Role in CRM 2011 through js ? RRS feed

  • Question

  • Hello,

    How to fetch all users for a specific Security Role in CRM 2011 through js ?


    Thursday, August 8, 2013 9:01 AM

Answers

  • You can create a QueryExpression or FetchExpression that joins the systemuser entity to the systemuserroles intersect entity and then to the role entity


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:36 AM
    Thursday, August 8, 2013 12:55 PM
    Moderator
  • HI,

    You can construct the Soap Query and retrieve all system User for the Role using Jscript. The below XML will give you an idea to construct the query.

      <entity name="systemuser">
        <attribute name="fullname" />  
        <attribute name="systemuserid" />
        <link-entity name="systemuserroles" from="systemuserid" to="systemuserid" visible="false" intersect="true">
          <link-entity name="role" from="roleid" to="roleid" alias="aa">
            <filter type="and">
              <condition attribute="roleid" operator="eq"  value="{0C66E009-E9D7-E111-A9AC-00155D3BDF4D}" />
            </filter>
          </link-entity>
        </link-entity>

    Hope this helps!

    Thanks!

    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:36 AM
    Thursday, August 8, 2013 6:27 PM
  • Don't forget Teams if you use Teams to assign additive roles to users. You may not be counting on that feature, but looking purely at systemuserroles is not going to get you every role that a systemuser is able to act as if there are any additive roles gained via team assignments.
    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:36 AM
    Thursday, August 8, 2013 7:47 PM

All replies

  • You can create a QueryExpression or FetchExpression that joins the systemuser entity to the systemuserroles intersect entity and then to the role entity


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:36 AM
    Thursday, August 8, 2013 12:55 PM
    Moderator
  • HI,

    You can construct the Soap Query and retrieve all system User for the Role using Jscript. The below XML will give you an idea to construct the query.

      <entity name="systemuser">
        <attribute name="fullname" />  
        <attribute name="systemuserid" />
        <link-entity name="systemuserroles" from="systemuserid" to="systemuserid" visible="false" intersect="true">
          <link-entity name="role" from="roleid" to="roleid" alias="aa">
            <filter type="and">
              <condition attribute="roleid" operator="eq"  value="{0C66E009-E9D7-E111-A9AC-00155D3BDF4D}" />
            </filter>
          </link-entity>
        </link-entity>

    Hope this helps!

    Thanks!

    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:36 AM
    Thursday, August 8, 2013 6:27 PM
  • Don't forget Teams if you use Teams to assign additive roles to users. You may not be counting on that feature, but looking purely at systemuserroles is not going to get you every role that a systemuser is able to act as if there are any additive roles gained via team assignments.
    • Marked as answer by DynamicsCRM31 Monday, August 12, 2013 6:36 AM
    Thursday, August 8, 2013 7:47 PM