Isn’t that title a mouthful? The thing is when you read the microsoft documentation on this feature it’s mostly code instructions apart from how to create a really basic notifications. But what if I don’t want to use JavaScript and still want those fancy pancy navigation links in my notifications? Here is how.
As some of you know I’ve been away for a bit going through treatment for breast cancer (if you want to hear more about it I recorded a podcast with Mark Smith about it). So what do you do when you come back after 10 months away without as much as opening your computer? How do you catch up?
Well I started with looking through the past two release notes I missed and there is especially one function that caught my attention more than others. IN-APP NOTIFICATIONS – say what now?! How long have we wanted something like this to offer to our customers to replace the constant requirement of e-mail notifications (yuck).
So this was part of the wave 1 2021 release notes but it just got released into preview in late august 2021. So note that this is not a feature to use in your implementations just yet, which also probably (hopefully) is why it’s a bit messy to turn the feature on. I followed this excellent blogpost by Chime Okure to turn it on in my environment.
Now time for the fun part! Let’s create a notification. I start by using the Dataverse (oh, apparently new name) connector using the trigger “When a row is added, modified or deleted” (Row? Added? It’s a whole new language to me but very well…)
Define when you want to trigger a notification, in my example I simply choose to send a notification to the Account Owner when an Opportunity is created on that Account. Next add a Dataverse action called “Add a new row” and choose the Notifications table.
Here you have a screenshot from Microsoft’s documentation about the table and what information you should populate in the action. If I just choose Title, Owner and Body I’m left with a simple notification but let’s focus on the Data column for a bit.
In the data column you can define if you want
Doesn’t that sound awesome?
First I want to make you aware of the “navigationTarget” property that we will define in the JSON.
My examples will open the record navigation links in a dialog and my view navigation links “inline”. This is because you get an unpleasant error if you try to open a view in dialog (I was tearing my hair out figuring that out and that is saying a lot since I’m really not keen on going bald again like during chemo.)
The most straight forward notification is to open a specific record that the notification is about. It could look something like this:
Take this JSON below and copy and paste it into your data column. Change title, table and add dynamic content (record id) marked in red. It’s the “pagetype=entityrecord” that defines that it is a row and not a view.
{
"actions": [
{
"title": "Display title of Navigation link",
"data": {
"url": "?pagetype=entityrecord&etn=<TABLE>&id=<Dynamic content>",
"navigationTarget": "dialog"
}
}
]
}
This is how it looks in my action
Now another common use case would be to have a link to a view in the notification. In this example I trigger on an new Opportunity but the navigation will take the user to a view with all Open Opportunities.
Let’s take the same JSON object as above and change pagetype to “entitylist” and add “view” as shown here in bold.
{
"actions": [
{
"title": "Display title of Navigation link",
"data": {
"url": "?pagetype=entitylist&etn=<TABLE>&viewid=<Dynamic content>",
"navigationTarget": "inline"
}
}
]
}
Again: Note that a VIEW link will NOT work with navigationTarget “dialog”.
This is what my action looks like:
Ran into some funny business finding that view ID too, so new blog post about that coming later this week but in short it’s the same principle as getting the record ID.
Sometimes you might want several navigation links in the notification. In my example below I’ve chosen a link to both the relevant Account and the relevant Opportunity.
What you do to accomplish this is really just duplicate that part of the JSON (bold part below) and update with the accurate entity/table name, dynamic content and title.
{
"actions": [
{
"title": "Display title of Navigation link",
"data": {
"url": "?pagetype=entityrecord&etn=<TABLE>&id=<Dynamic content>",
"navigationTarget": "dialog"
}
}
]
},
{
"title": "Display title of Navigation link 2",
"data": {
"url": "?pagetype=entityrecord&etn=<TABLE>&id=<Dynamic content>",
"navigationTarget": "dialog"
}
}
]
}
This is how it looks in my action:
Be careful, for your users sake, and don’t abuse this by putting to many actions in the same notification because it looks messy to say the least. Yikes.
Okay folks. Don’t forget that this is a preview feature and much can happen until it comes out in GA. This might not be the best way to use this function then. Only time will tell!
That was fun writing but totally exhausting too. Time for my nap. Ciao!