In this article, we are going implement a notification message in the customer service workspace when a new case is created or updated.
We are going to activate In-app notification features in model-driven apps and write a plugin code to get messages.
- Sign into https://make.powerapps.com/
- Open the solution that contains the model-driven app.
- Select the model–driven app and select the edit.
- Click on settings, Navigate to Features, and search for in–app notifications and active.
![Features setting]()
![Teams chats]()
Write a plugin code to get a notification in the customer service workspace when a new case is created in the cases entity.
Open Visual Studio and select Create New Project.
![Visual Studio new project]()
Search for the class library, select the Class Library (.Net Framework), and click on Next.
![Class Library .NET Framswork]()
Give the project name, select the latest .Net framework, and click on Create.
![Configure project]()
To install CRM Core Assemblies right, click on solution, select Manage NuGet packages as shown in the below screen, and search for Microsoft.CRMSdk.CoreAssemblies and install it.
![Solution explorer]()
![Microsoft CoreAssemblies]()
Next, to install the plugin registration tool in the solution right, click on a solution once aging, select Manage NuGet packages as shown in the below screen, and search for Microsoft.CRMSdk.XrmTooling.PluginRegistrationTool and install it.
![Install Nuget package]()
The below references will be added to the solution once we install both packages.
![Solution explorer]()
Next Update the below code in Class1.cs and build the solution.
using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;
namespace InApp_Notofication_Demo
{
public class Class1 : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName != "incident")
{
return;
}
if (context.MessageName == "Create")
{
var request = new OrganizationRequest()
{
RequestName = "SendAppNotification",
Parameters = new ParameterCollection
{
["Title"] = "A New Case has been Created",
["Recipient"] = entity.GetAttributeValue<EntityReference>("ownerid"),
["Body"] = "A new Case has been created you.",
["Expiry"] = 1209600,
["Actions"] = new Entity()
{
Attributes =
{
["actions"] = new EntityCollection()
{
Entities =
{
new Entity()
{
Attributes =
{
["title"] = "Open Case",
["data"] = new Entity()
{
Attributes =
{
["type"] = "url",
["url"] = $"?pagetype=entityrecord&etn={entity.LogicalName}&id={entity.Id}",
["navigationTarget"] = "newWindow"
}
}
}
}
}
}
}
}
}
};
service.Execute(request);
}
}
}
}
Next open the plugin registration tool to register your plugin, once tool get open click on Create New Connection button, a new window will get open there please select Display list of available originations and show advanced check box and enter the user id and password as show in below screen.
![Create new connection]()
Select your environment for list options and click on login.
![Asia pacific area]()
Once the tool opens, click on register, select register New Assembly, and show in the below screen.
![Register]()
A new window will open. Select our DLL from Load Assembly. And click on the register selected plugin.
![Register new Assembly]()
Once the plugin is registered right click on that and select Register New Step.
![Customer Service Trial]()
Select the Message as “Create” and the Primary Entity as “incident”.
Select the execution stage as “PostOperation” as shown below screen.
![Register new step]()
![Plugin]()
Finally, Navigate to CRM customer service workspace and create new cases in CRM.
Once a new case is created in the CRM, a notification message is received in the notification section, as shown below screen.
![Customer service agent dashboard]()
![Customer table]()
![Notifications]()
Thanks for Reading…!