D365 – System Views – Does Not Contain Data

The Advanced Find functionality within D365 v9 allows us to search for records that have no data in a related entity – a NOT IN query. For example, provide a list of Contacts that are not the Primary Contact for an Account.

advanced-find-NOT-IN

However, if we try to create the same using a System View there is currently no option to do a NOT IN query.

system-view-filter

To create a System View which contains a NOT IN query I had to complete the following steps.

  1. Create a basic System View with the required column layout and Publish the View.
  2. Using XrmToolBox and the View Designer Plugin I opened the System View and edited the query (using FetchXML Builder)
  3. Finally, save and publish the changes to the System View.

NOT-IN-FetchXML

A few things I have found when creating NOT IN System Views.

    1. The System View does get created in the list of System Views for the entity and displays the correct content.

system-view-1

    1. When you open the Advanced Find from the System View, the filters for the System View are displayed correctly but the name of the System View we created is not listed.

system-view-2

    1. When you re-open the System View in the D365 solution after you have made the NOT IN modification, the option to Edit the filter criteria is no longer available. Any additional changes to the System View would need to be made using the XrmToolBox View Designer Plugin.

system-view-3

Advertisements

D365 Portals, Liquid Templates and FetchXML

My challenge today was to create a Web Template for a D365 Portal that returned a JSON object from a FetchXML query. There are a few blog posts around on how to achieve this, including this one from my colleague Nadeeja.

The complication for me was the FetchXML contains an ‘in’ operator which would contain a dynamic number of values.
fetchXML
The solution requires the creation of a Liquid array which can then be used in the construction of the FetchXML. To create the array I pass a comma separated list of values of GUIDs I need included in the query. Using the Liquid Assign variable tag i can create the array.
{% assign groupIds = request.params['groupIds'] | split: ',' %}
Within the Web Template I can iterate through the array as part of the construction of the FetchXML query.
fetchXML-2
To test the response I created a POST within Postman to the URL and supplied the named parameter, groupIds, as a comma separated list of values. The POST request is made using form-data and returns the relevant number of items based on the number of items in the groupIds array.
postman