USD 2.2 contains a cool new feature to pop-up notification forms, in this blog post I will explain how this new feature works.

First of all, what is a notification and when might you use them? Think of a notification as a pop-up that can be used to alert the agent to “something”. Then clicking buttons on that notification can trigger actions or events within USD. Microsoft give an example of a notification being used to warn the operator of the maximum number of sessions. Maybe you can think of more inventive uses, such as warning the agent that customers support contract has expired and offering an option to renew.

Below you can see that I have given an example of a notification. A few things to notice …..

  1. I have a timer on my notification, if after 60 seconds the agent hasn’t selected a button the notification will close. (Tip:
    This does trigger an event so you could fire actions if the agent does nothing!)
  2. I have a button called “EVENT”, I have used this to show how to trigger an event from the notification.
  3. I have a button called “ACTION”, I have used this to show how I can call an action from the notification.
  4. In the notification, I am showing the maximum number of sessions. I have done this to show how replacement parameters can be included in the notification.

So, let’s have a look at how to achieve this effect. The steps involved are ….

  1. Create a hosted control.
  2. Create a form.
  3. Create an action.
  4. Trigger the action.

Step One – Create a Hosted Control

Firstly, I created a hosted control using the new component type of “Popup Notification”.

Notice that I have mode my notification global. This is optional as notifications can also be part of the session.

It is also possible to have multiple notification. But if you display them all in the same location you’d see the last one displayed as they would overwrite each other.

Whilst I’m talking about the hosted control let’s have a quick look at the default events. You can trigger the Cancel or Ok events from code we’ll see in a second. Also the “TimeOut” event can be automatically triggered if the user does not respond to the notification within a given time period.

I mention these as when you consider how you might make use of the Popup Notification you may want to think about adding multiple actions to one (or several) of these events.

Step Two – Create a Form

If you aren’t familiar with XAML this will be the clever bit! I’m not a hard-core coder. But I’ve managed to work out enough of the code to get this working. So don’t let this step scare you.

In the forms option of USD settings, I created a new form. My form looked like this.

I created the XAML in the markup field by copying some I found and tweaking it.

Tip:
Any code changes are best done in a XAML editor and then pasted into the markup field once completed.

My entire code looked like this, please copy and tweak. J

<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:CCA="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics"
BorderBrush="Blue" BorderThickness="1">
        <Grid Background="AliceBlue" Height="100" Width="400">
<Grid.Resources>
 <CCA:CRMImageConverter x:Key="CRMImageLoader" />
<Style x:Key="ImageLogo" TargetType="{x:Type Image}">
<Setter Property="Width" Value="16" /> 
<Setter Property="Height" Value="16" /> 
<!--<Setter Property="Margin" Value="5" /> -->
</Style>
    </Grid.Resources> 
            <Grid.RowDefinitions>
                <RowDefinition Height="75"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
            </Grid.ColumnDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50"/>
                    <ColumnDefinition Width="350"/>
                </Grid.ColumnDefinitions>
<Image Style="{DynamicResource ImageLogo}" Source="{Binding Source=msdyusd_Email16, Converter={StaticResource CRMImageLoader}}" Grid.Column="0" />
                <TextBlock TextWrapping="Wrap" Grid.Column="1" Text="The text for the notification will go here. You can insert replacement parameters! Example .... You can have a maximum of [[$Global.maxNumberOfSessions]+] concurrent sessions open."/>
            </Grid>
            <Grid Background="SkyBlue" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200"/>
                    <ColumnDefinition Width="100"/>
     <ColumnDefinition Width="100"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0">
                    <Run Text="The notification closes in " />
                    <Run Text="{Binding TimeoutProperty}" />
                    <Run Text=" seconds"/>
                </TextBlock>
              <Button Name="btn1" Height="20" Width="90" Grid.Column="1" Foreground="Black" Command="CCA:ActionCommands.UIIEvent" CommandParameter="Cancel">EVENT</Button>
              <Button Name="btn2" Height="20" Width="90" Grid.Column="2" Foreground="Black" Command="CCA:ActionCommands.DoActionCommand" CommandParameter="http://uii/CRM Global Manager/DisplayMessage?text=An Action!">ACTION</Button>
            </Grid>
        </Grid>
    </Border>  

To help explain the code let’s look at a few specific elements;
Replacement Parameters

Notice how in the text I have inserted a replacement parameter. In my example I have used [[$Global.maxNumberOfSessions]+] but you could use any replacement parameter.

 <TextBlock TextWrapping="Wrap" Grid.Column="1" Text="The text for the notification will go here. You can insert replacement parameters! Example .... You can have a maximum of [[$Global.maxNumberOfSessions]+] concurrent sessions open."/>

The timer

Later in this post I will show how the action that calls the notification can set a timeout value. Then the code below can be used to show the timer in the notification.

<TextBlock Grid.Column="0">
                    <Run Text="The notification closes in " />
                    <Run Text="{Binding TimeoutProperty}" />
                    <Run Text=" seconds"/>
</TextBlock>

The EVENT Button

In my notification, I had a button that called an event. In my example clicking the button will trigger the “Cancel” event on the notification hosted control. (Which will close the notification!)

In the code below I hope you can see that clicking the button will trigger a command. CCA:ActionCommands.UIIEvent This command will trigger whatever event is referenced in the CommandParameter. In my example the “Cancel” event.

  <Button Name="btn1" Height="20" Width="90" Grid.Column="1" Foreground="Black" Command="CCA:ActionCommands.UIIEvent" CommandParameter="Cancel">EVENT</Button>

Tip:
Don’t forget you aren’t limited to the out of the box events. You could create a custom event if required.

The ACTION Button

In the notification, I included an action button. In my simple example this just triggered a DisplayMessage action but you could trigger any action.

In the code below clicking the button will trigger a command. This time CCA:ActionCommands.DoActionCommand. The command parameter then contains the url needed for the action.
In my example the hosted control is CRM Global Manager, the action is “DisplayMessage” and the data field would contain “test=An Action!”

 <Button Name="btn2" Height="20" Width="90" Grid.Column="2" Foreground="Black" Command="CCA:ActionCommands.DoActionCommand" CommandParameter="http://uii/CRM Global Manager/DisplayMessage?text=An Action!">ACTION</Button>

I hope you can see that you might not be a XAML expert but you can probably take this example an adapt for your requirements.

Step Three – Create an Action

Next, we need an action to display the notification. Mine is shown below.

The hosted control is the popup notification control we created in step one. And the action is Show.

Then in the data field I have defined the name of the form to display, its position and length of the timer. So ….

formname = NotificationForm
top =-86
left = 1
timeout = 60

Tip: Other actions that you might want to use on the notification popup include “Hide” and “Close”.

Step Four – Trigger the Action

You could opt to trigger this action (and load the notification) from multiple different points. In my simple example, I’ve done it when a session opens. But you could add this type of action to the BrowserDocumentComplete of a tab or maybe to an agent script answer etc.

See below that I have added the action to my SessionNew event on my CRM Global Manager.

There we have it, a cool new feature to popup notifications and control what happens next by calling actions or events as required. What do I think? I think it is great. The only downside is that creating the form needs knowledge of WPF / XAML. I’m not a coder! But with a little help from a friend I managed to understand enough to get this feature working. So, you should also be fine.
J

6 responses to “USD – Notifications”

  1. […] NotificationsOver the past year or so I have written many blog posts regarding Unified Service Desk (USD) for Microsoft Dynamics CRM. The thing with blogging is you create posts in a random order with no sense of a purpose or direction. I therefore wanted to take stock by organising my USD posts into one group. (or book if you like!) […]

    Like

  2. You can use Expression Blend to create your XAML. It’s a nice gui editor for building these forms.

    Like

    1. I haven’t used expression blend. I guess give it a try would be more answer. But we did we visual studio, so I can’t see why not.

      Like

  3. Is there is any possibility of displaying the forms which is created using “Forms” option in USD?

    Like

    1. Hi Aravindh

      I have only used the forms option with notifications. Looking at those might give you some pointers.

      USD – Notifications

      Neil.

      Like

    2. There is a FormViewer hosted control that displays your form as a standard hosted control but it is not in the product at this point. It is available in the USD Component Library open source project… https://blogs.msdn.microsoft.com/usd/2016/08/26/usd-component-library-open-sourced/

      Liked by 1 person

Leave a comment

Trending

Website Powered by WordPress.com.