Dynamics CRM: AND/OR in filtered views
Views play a pivotal role in Dynamics CRM. Not only it is the main method with which interact with records of given entities, but it is also the foundation for creating charts.
For a client, I had to particularly create several views for the Goals entity. In this process I noticed that the “My Group’s Revenue Goals for This Period” doesn’t show exactly what it says it does. This isn’t necessarily a bad thing, but it can be slightly confusing.
According to the description of the view “My Group’s Revenue Goals for This Period”, this view “Displays all the active revenue goals in the current fiscal year that have the current user as the goal owner or manager”.
However, I noticed that this isn’t entirely true. This view does display all the active revenue goals that have the current user as the goal manager, but NOT as the goal owner. When analysing the goal filter, I noticed that it shows the following criteria:
- Status EQUALS “Active”
- Goal Metric EQUALS “Revenue”
- FROM “This Fiscal Period”
- TO “This Fiscal Period”
- Manager EQUALS “Current User”
- Goal Owner DOES NOT EQUAL “Current User”
The last two lines are crucial to define this view. First we define that we want to include records where manager EQUALS the current user, but then the next criteria says that Goal Owner DOES NOT EQUAL current user. As a result, the view will only display records where the current user is the manager and not the owner of the goal record.
I do need a view to include both the manager records and the records of the manager’s team. But instead of modifying this view, I opted to create a new one. I think it will be useful to have two views, like this:
- My Group’s Revenue Goals for This Period: Only display records where the current user is the manager and not the owner of the goal record
- My/My Group’s Revenue Goals for This Period: Only display records where the current user is either the manager or the owner of the goal record
In order to do this, I saved a copy of the default view as “My/My Group’s Revenue Goals for This Period”, then I edited its filter properties as follows:
As you can see per the above image, there is an OR statement which basically sets that records where the current user is the manager or where the current user is the goal owner should e displayed.