Create A Portal Inbox & Messaging Process

*** 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.

4 thoughts on “Create A Portal Inbox & Messaging Process

  1. Hi Megan. I hope you are fine. Im trying unsesfully replicate this on my trial, but well so Im still triying.
    The question is, Why not using the portal comments ? I dont know if you say something about it on some youtube video.

    Portal comment have note too.
    The count of the message Inbox is visualy wonderfull. Is not posible make this with the Portal Comments Entity?

    There are few places to look for information about the portal and this is one of the best.

    Thanks.

    1. Hi Javier, thanks for the lovely comment! Good question. You could certainly use the portal comment as the entity to count and display with the number unread, however, you would need to do quite a lot to the entity to change it with the change to the status etc. Also, the portal comment is used predominately on the case entity in the portal. I wanted a way to keep the messages completely separate from the comments as they go back and forth both ways (from a user to a contact record). It would have been a bit of a challenge to try and find the right query to keep it all apart from one another. Hope that makes sense!

Leave a Reply

Your email address will not be published. Required fields are marked *