FetchXmL snippets for interacting with Dataverse

Currently being written

This post provides some helpful FetchXmL snippets for interacting with Dataverse

1.) The following FetchXml determines if the logged in user is a Contoso Team Leader. Note:

  • at the top level business unit, the role GUIDs don’t change between environments (child BU roles do), hence why parent root role is referenced.
  • In this example, there are two ‘Contoso Team Leader’ role records, one at the Contoso BU level and one at the child ‘Contoso Pharmaceuticals’ BU level
<fetch>
 <entity name = "systemuser" >
  <filter>
   <condition attribute="systemuserid" operator="eq" value="${user}" />
  </filter>
  <link-entity name="teammembership" intersect="true" visible="false" to="systemuserid" from="systemuserid" >
   <link-entity name="team" to="teamid" from="teamid" alias="team" />
    <link-entity name="teamroles" to="teamid" from="teamid" intersect="true" visible="false" >
     <link-entity name="role" alias="role" to="roleid" from="roleid" >
     <filter>
      <condition attribute="parentrootroleid" operator = "eq" value = "${this.SecurityRoles.ParentRootRole_Contoso_Team_Leader}" />
     </filter>
     <filter>
      <condition attribute="businessunitid" operator = "eq" value = "${this.BusinessUnit.Pharmaceuticals}" />
     </filter>
    </link-entity>
   </link-entity>
  </link-entity>                                  
 </entity>
</fetch>