0
votes

I would like to get rid of the Social Pane on Dynamics 365, by replacing it with a Subgrid on the account form which would list the activities of the account and the activities of the account's contacts. We are currently using the "parentcustomerid" lookup to associate a contact to an account which is not hierarchical. I cannot find a solution with FetchXML to get what I want. The following FetchXML would work if there was a hierarchical relation:

<fetch>
<entity name="activitypointer" >
<attribute name="activityid" />
<attribute name="regardingobjectid" />
<attribute name="subject" />
<attribute name="regardingobjecttypecode" />
<filter type="and" >
  <condition attribute="isregularactivity" operator="eq" value="1" />
  <filter type="or" >
    <condition entityname="accountparty" attribute="accountid" operator="eq-or-under" value="5D8E9289-7F86-E811-910D-0050568B95ED" />
    <condition entityname="contactparty" attribute="contactid" operator="eq-or-under" value="5D8E9289-7F86-E811-910D-0050568B95ED" />
  </filter>
</filter>
<link-entity name="activityparty" from="activityid" to="activityid" link-type="outer" alias="activityparty" >
  <link-entity name="account" from="accountid" to="partyid" link-type="outer" alias="accountparty" />
  <link-entity name="contact" from="contactid" to="partyid" link-type="outer" alias="contactparty" >
    <link-entity name="account" from="accountid" to="parentcustomerid" link-type="outer" alias="contactaccount" />
  </link-entity>
</link-entity>

The goal is to have a plugin that catches the query in pre-operation in order to add the conditions and filters needed.

3
This was not allowed as an answer, so I just write it as a comment: This is a solution to your problem jonasrapp.net/2016/05/hierarchy-activitiesJonas Rapp
@JonasRapp I've found this link before and it helped me understand but the relation between contacts and account is made through "parentcustomerid" which is not a hierarchical relationship so it cannot work unfortunately.Hubert Solecki

3 Answers

2
votes

You could solve this by linking the activities related to contacts directly to their parent account, with a custom lookup in the activity entity and probably a Retrieve/RetrieveMultiple plugin to automagically fill it based on if the regardingobjectid is a contact.

Done that, you only need to refer to that field in the grid.

We used a similar approach to make a "rollup of rollups" spanning more than 1 relationship.

1
votes

This kind of rollup is easy to achieve with custom HTML webresource with bootstrap & our own js libraries to handle web api calls/fetchxml queries. We are doing this today.

As we cannot do UNION in fetchxml, we may have to merge couple of resultsets, so we can use jQuery datatables to merge/visualize the results.

Also this approach is easy to amend, debug rather intercepting server calls for custom fetchxml queries.

0
votes

As you are have concluded already, the core to solve this is to use the UnderOrEqual condition with the query.

This feature may be difficult (afaik it is impossible) to implement in the way you want to by using the View Designer. So you need to add some code to make this happen.

While the approach to create custom webresources and use a custom grid might be easier to debug, it will require quite a lot of custom code and controls.

Another approach would be to add a standard subgrid with an "Associated View" for activities related to the parent account to the form, then add a pre RetrieveMultiple plugin that identifies the query and then tweaks the query to work for your needs.

You are then using standard controls and features, that will be upgradeable and still follow possible design changes from Microsoft etc.

To see a fully working ready to use solution, the following article describes this pattern in detail: https://jonasrapp.net/2016/05/hierarchy-activities/