I would say, This post is an extension to Neil’s USD – Notifications post (link). I want to use it with one another kind-of real world scenario. Let’s say being a Call center Manager, you want to display an important message – “XYZ application processing has been stopped for today, Please make sure you are not accepting calls for this application” to all your agents.
Before USD 2.2, Maybe you can go with DisplayMessage action of CRM Global Manager but not a foolproof one. But the new Notifications in USD2.2 would help a lot in achieving this scenarios more efficiently.
Consider the same scenario and we want to show it whenever the user starts a session and user will have flexibility to stop it. Let's see the steps involved.
Create the hosted control
Create the required “FORM” record with XAML
Create the action calls required to Open the notification, Close the notification, Don’t show again notification
Create the custom event for Don’t show notification
Create the Hosted Control
Note: This step is not required if you have OOB configurations in your Org. If you have OOB configurations, you can use “GlobalNotification” control.
Create a new Hosted control with name “GlobalNotification” and type as “PopupNotificaiton” as shown below. Make sure the control is marked as Global as shown below.
Create Custom Event to handle “Don’t Show again”
Navigate to Events section of the GlobalNotification hosted control, create a new Event with name “DontShowAgain” as shown below.
After save&close, this is how you should see the events of GlobalNotification hosted control
Create a new FORM record for the UI of the message box
Navigate to Unified Service Desk >> Forms and Click on New to create new Form record.
Give the form some meaningful name. In my case I have created with a name “ShowNotification” with the following XAML. Make a note of the Name of the form, later on we are going to use it in action calls as well.
Note: Following is the XAML I have created which I found looking nice :). But you may find it offbeat, make yourself comfortable in making the changes required for your environment, but keep in mind if you are changing any event names/command parameters/replacement parameters etc. then you have to change accordingly further in action calls.
<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"
xmlns:Converters="clr-namespace:USDConverters;assembly=USDConverters"
BorderBrush="Black" Background="DarkGray">
<Grid Height="auto" Width="600" Margin="3" Background="White">
<Grid.Resources>
<!--<Converters:CommandParameterConverter x:Key="CommandParameterConverter" />-->
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="100" MaxHeight="100" />
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid Background="#444444" Grid.Row="0" Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60*"/>
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
<TextBlock Foreground="White" Grid.Column="0"
Margin="9,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"
FontSize="12" TextWrapping="Wrap" FontFamily="Calibri">
<Run Text=":: Message ::" />
</TextBlock>
</Grid>
<Grid Grid.Row="1" Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="10">
<TextBlock Foreground="Black" Grid.Column="0" TextWrapping="Wrap" FontFamily="Calibri" >
<Run FontSize="16" Text="[[$Global.Message]+]" />
</TextBlock>
</ScrollViewer>
</Grid>
<Grid Grid.Row="2" Background="#F0F0F0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Height="22" Width ="120" Background="Green" Foreground="Black"
Command="CCA:ActionCommands.UIIEvent"
CommandParameter="Ok">
<Button.Content>
<Bold>OK</Bold>
</Button.Content>
</Button>
<Button Grid.Column="0" Height="22" Width ="120" Background="Green" Foreground="Black"
Command="CCA:ActionCommands.UIIEvent"
CommandParameter="DontShowAgain">
<Button.Content>
<Bold>Don't Show again</Bold>
</Button.Content>
</Button>
</Grid>
</Grid>
</Border>
And this is how the Form record looks like.
And this is how the design of it looks like.
Now, let's create Action calls
To Open notification: Create a new Action call with the following details.
Name
|
Show Notification Message (General)
|
Order
|
100
|
Hosted Control
|
GlobalNotification
|
Action
|
Show
|
Data
|
formName = ShowNotification
top = 40
left = 30
|
Preview
|
|
To Close Notification: We need to handle the notification closing if we are working with custom event handlers. Remember we have created a custom event in step 1 for DontShowMessageAgain, we are going to attach this close notification action call later to the event. Create a new action call with the following details.
Name
|
Close Notification
|
Order
|
10
|
Hosted Control
|
GlobalNotification
|
Action
|
Close
|
Preview
|
|
Action call to Create User Setting for Don’tShowagain: Once when user presses don’t show again, we will create a user setting record which we can use in the action call as a condition so that the message won’t popup to user again.
Name
|
Set user settings for DontShowNotification
|
Order
|
20
|
Hosted Control
|
CRM Global Manager
|
Action
|
SaveSetting
|
Data
|
name=DontShowNotificationAgain
value=1
|
Preview
|
|
Now, the last step before closing the action calls, to add the condition for “Show Notification Message (General)”. This action call should only fire
When there is a message to show. The idea is to place the message in the USD Options entity as a setting of USD. This message will then become part of USD’s $Global replacement parameter.
When there is no user settings record for DontShowNotificationAgain. Basically, when we call the Save Setting action, it would create a new record in User Settings record and further would be available as part of USD’s $Setting replacement parameters.
So, let’s open the “Show Notification Message (General)” action call which we created previously and add the condition as shown below.
Condition
|
"[[$Global.Message]+]" !="" && "[[$Settings.DontShowNotificationAgain]g+]" !="1"
|
Finally the action call should look like:
Now, let’s attach the action calls to their corresponding events.
As we want to show the message every time a session is started, The “Show Notification Message (General)” should be attached to “SessionNew” event as shown below.
When user clicks on the “DontShowAgain” button in the UI, we should set the setting and close the message box. So, let’s add both “Set user settings for DontShowNotification” and “Close Notificaton” to the “DontShowAgain” event which we created in step1 as shown below.
That’s it, we have almost assembled all bits. The left out part is the message that we want to show. Let’s create a new Option record. Navigate to Unified service desk >> Options >> Click New and create a new Option record with the following information.
Global Options
|
Others
|
Name
|
Message
|
value
|
XYZ application processing has been stopped for today, Please make sure you are not accepting calls for this application
|
Preview
|
|
All right, we are all set to go. Open the USD and start a new session and check, you should be able to see something like this.
Observe that, if you simply click OK and start another session, it will show the same message again. But If you click on Don’t Show Again button, then the message will not come again for further sessions. If you check the user settings now, you should be able to see a record got created automatically with DontShowMessageAgain value set to 1.
Deleting this record, will pops up the message again to user. Hope this helps in understanding the uses of this Pop up notifications. I can see lot of benefits with this kind of popup messages. The good part of it is, it’s a no code solution again and any admins can easily configure the required messages. Except for the XAML which I think we don’t need to change all the times, just setup once and use the same everywhere :).
I’m exploring further on how to make it time bounded by combining it with my previous post of Javascripts in conditions. Will share you the details further if I found it is interesting. Till then, Happy new year :)