Reputation: 121
I have a table in dataverse which has a column called "Department" and I need to dynamically show only records where department is same as current logged in user's department (one of the user property). I have done the same using subgrid, but like to do it in the table view directly, is it possible at all?
Upvotes: 0
Views: 954
Reputation: 198
View does not support dynamics filter directly, but as the dynamics filter only related to current user - it can be done in a tricky way with operator "eq-userid".
Assuming the main entity is Account, and the field is new_department(string).
The fetchXml should look like this:
<fetch version="1.0" output-format="xml-platform" mapping="logical" savedqueryid="75a04335-6313-ef11-9f89-000d3a8196f4">
<entity name="account">
<attribute name="name" />
<attribute name="ownerid" />
<attribute name="accountid" />
<attribute name="new_department" />
<link-entity name="systemuser" from="new_department" to="new_department" link-type="inner" visible="false">
<filter type="and">
<condition attribute="systemuserid" operator="eq-userid" />
</filter>
</link-entity>
<order attribute="name" descending="false" />
</entity>
</fetch>
The link-entity is linked on "new_department" NOT an id field.
Note:
Due to the special linked-on field, the view's fetchXml can only be updated with code. View stores in savedquery entity, you can create view and edit the layout in UI and then update the fetchxml column by code. Also it would show an empty tag in advanced find:
Upvotes: 0