*** NOTE: ALL INFORMATION IS ACCURATE AT DATE OF PUBLISHING ***
If you log in to any social media platform you’ll see a red notification badge telling you how many unread messages you have. We don’t have this in the Microsoft Dynamics Portal by default, but with a little effort we can create this, and provide the user with a notification count and an inbox to browse through each time they log in, ending up with something like this:
The first thing we are going to do is add a new custom entity for a ‘Portal Message’. Although we already have Portal Comments, we want to keep this separate from those, so the new entity is needed. Make sure you check to define as an activity entity.
Also make sure you enable ‘Change Tracking’ from the Data Services section. This is important to make sure when new Portal Messages are created in D365, they will display pretty much right away in the portal for the user. If you don’t check it, you will see that it can take a while for them to display, even to the point where you need to restart the portal to see them. Not a smooth process at all!
For your fields, you shouldn’t need to add any. We want a subject, description, status reason, and date read. You can add a new field for data read, or you could use the ‘closed’ or ‘completed’ date of the activity. For your Status Reason field, change the Active status of ‘Open’ to ‘Unread’, and the Inactive status of ‘Completed’ to ‘Read’. We are going to use this in the portal so the user can indicate when they have read a message. Next, we will add a new field to the Contact record. This will be a rollup field to count the number of unread Portal Message records where the Contact is set as the Regarding on the activity. It should be a Whole Number.
For the details on the roll up, select Portal Messages as the Related Entity , and set the Filter to be if the Status Reason is ‘Unread’. Set the Aggregation as the Count of all Portal Messages.
Now we need a couple of workflows. The both are linked to the Portal Message entity, but the first one runs when a new record is created. It’s got to be a real time workflow. We want to force a recalculation of the roll up fields for Unread Messages each time a new Portal Message is created. To do this, we need to download a solution from Demian Rasko, the Dynamics 365 Workflow Tools solution which you can find here. We are going to use the Calculate Rollup Field option in this workflow.
For the Calculate Unread Messages step using Demian’s solution, you will add in the name of the rollup field created, and use the Parent Record URL from the Regarding Contact relationship, then the RecordURL(Dynamic) value. This means when the Portal Message is created, the rollup field for the related Contact will recalculate. We are adding in the Update Contact step at the end which forces it to then be updated and displayed accurately in the Portal. Without that step, the user wouldn’t see the correct updated field.
Our second workflow will only run upon initiation by the portal user. When they are viewing a message they will have a button to mark it as read. That will then kick off this workflow which will change stamp the date of when it was read, change the status to read, and then recalculate the rollup field to get the new number of unread messages. It is also a real time workflow, but only running on-demand.
So, our condition first checks to make sure the Status Reason of the Portal Message is ‘Unread’, then it updates the Date Read field using the date from the workflow process running. We change the status of the Portal Message to Read, then we use the step to calculate the rollup field for the unread messages. Finally, we want to force an update of the Contact record for the same reasons as we did in the first workflow.
Check out the latest post:
Masking Mode In Microsoft Clarity
This is just 1 of 285 articles. You can browse through all of them by going to the main blog page, or navigate through different categories to find more content you are interested in. You can also subscribe and get new blog posts emailed to you directly.