There are so many features of SSRS reports which are very less used but they can play a vital role in our report performance and productivity.
One such feature of SSRS reports is LookupSet.
SSRS Definition:
As per SSRS documentation a LookupSet may be defined as:
Use LookupSet to retrieve a set of values from the specified dataset for a name-value pair where there is a 1-to-many relationship.
For example, for a customer identifier in a table, you can use LookupSet to retrieve all the associated phone numbers for that customer from a dataset that is not bound to the data region.
Explanation:
In SSRS reports we can bind a table to a single dataset and due to that it becomes tedious to show the records from another dataset.
So we use LookupSet to fetch the records from another dataset based on a matching value between the current dataset and the target dataset.
For example, if we need to show the activity parties associated with an activity then we can use the LookupSet to achieve this.
Working:
Since it is not possible to fetch the related activity parties associated with an activity from OOB approach as shown in the below figure.
So we cannot fetch the To (Recipients) and From (Sender) of an activity using Advanced Find.
Workaround:
In reports we can achieve this using LookupSet, to achieve this we created two dataset i.e. dsActivitiesand dsActivityParties. Both the datasets have the ActivityId field in common so we used the following formula to fetch the To (Recipients) and From (Sender) of the activities shown in the report.
Formula:
To (Recipients):
=IIF(IsNothing(Join(LookupSet(Fields!activityid.Value, Fields!activityidValue.Value, IIF(Fields!participationtypemaskValue.Value = 2, Fields!partyid.Value, “”), “dsActivityParties”), “,”)),””,Join(LookupSet(Fields!activityid.Value, Fields!activityidValue.Value, IIF(Fields!participationtypemaskValue.Value = 2, Fields!partyid.Value, “”), “dsActivityParties”),”, “).Trim(“, “).Trim())
From (Sender)
=IIF(IsNothing(Join(Lookupset(Fields!activityid.Value,Fields!activityidValue.Value,IIF(Fields!participationtypemaskValue.Value =1,Fields!partyid.Value,””),”dsActivityParties”),”,”)),””,Join(Lookupset(Fields!activityid.Value,Fields!activityidValue.Value,IIF(Fields!participationtypemaskValue.Value =1,Fields!partyid.Value,””),”dsActivityParties”)))
Note:
Since the records returned by the LookupSet function are in the form of an Array so we use the Join function to show the record collection separated by comma (,).
Sample report:
After developing the report the report looks something like below:
Hope it helps if you are willing to show records from different datasets in a table.
There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!
The post Using LookupSet in SSRS reports to show activity parties related to an activity in Dynamics CRM appeared first on Inogic Blog.