Monday, 23 June 2025

How to convert plugin assembly (dll) into base 64 bytes using console application (C#).

 using System;

using System.IO;

using System.ServiceModel.Description;

using Microsoft.Rest;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Query;

using Microsoft.Xrm.Tooling.Connector;

namespace ConsoleApp2

{

    internal class Program

    {

        static void Main(string[] args)

        {

            string connectionString = @"AuthType=OAuth;

                Username=*****************;

                Password=*****************;

                Url=https://*****************.crm8.dynamics.com;

                AppId=*****************;

                 LoginPrompt=Auto";

            Console.WriteLine("Connecting to Dynamics 365..");


            using (CrmServiceClient serviceClient = new CrmServiceClient(connectionString))

            {

                if (!serviceClient.IsReady)

                {

                    Console.WriteLine("Failed to connect: " + serviceClient.LastCrmError);

                    return;

                }

                IOrganizationService service = (IOrganizationService)serviceClient.OrganizationWebProxyClient ?? (IOrganizationService)serviceClient.OrganizationServiceProxy;

                Console.WriteLine("connected to Dynamics Crm ");

                QueryExpression query = new QueryExpression("pluginassembly")

                {

                    ColumnSet = new ColumnSet("name", "content")

                };

                EntityCollection results = service.RetrieveMultiple(query);


                foreach (Entity plugin in results.Entities)

                {

                    string name = plugin.GetAttributeValue<string>("name");

                    string content = plugin.GetAttributeValue<string>("content");

                    if (string.IsNullOrEmpty(content))

                    {

                        Console.WriteLine($"Assembly '{name}' has no content.");

                        continue;

                    }

                    byte[] dllBytes = Convert.FromBase64String(content);

                    string fileName = $"{name}.dll";

                    File.WriteAllBytes(fileName, dllBytes);

                    Console.WriteLine($"Downloaded: {fileName}");

                }

                Console.WriteLine("All assemblies downloaded successfully.");

            }

        }

    }

}

Notes -Replace credentials as per your  CRM environment.

Download a plugin assembly (DLL) from Dynamics 365 CRM.

 CRM does not allow direct download of the DLL file from the UI. However, there are several ways to retrieve the plugin DLL from the CRM environment. we achieve this requirement using XrmToolBox.  

  • Open XrmToolBox.
  • Install and open Assembly Recovery Tool.
  • Connect to your Dynamics CRM instance.
  • It will list all deployed assemblies.
  • Select the assembly and click Download.
Connect D365 Environment 



Configuration ==> Tool Library ==>Search "Assembly Recovery Tool" and install.


Tool==>Assembly Recovery Tool.

Double click on "Assembly Recovery Tool" all Assemble file will be appear. 


Select "Assemble "and  click on "Export to Disk "


Note :- All Assemble file store under "pluginassembly" entity.







Saturday, 1 March 2025

How to Setup SLA in D365 Service module.

Setting Up SLA (Service Level Agreements) in Dynamics 365 Customer Engagement (CE)

A Service Level Agreement (SLA) in Dynamics 365 CE (Customer Service module) defines response and resolution times for service cases to ensure customer satisfaction. It helps in tracking, monitoring, and automating service commitments.


📌 Steps to Set Up SLA in Dynamics 365 CE

Step 1: Enable SLA in System Settings

Before configuring SLAs, ensure that SLAs are enabled:

  1. Navigate to: Customer Service Hub → Service Management → Service Terms
  2. Go to Service Configuration Settings
  3. Enable Service Level Agreements (SLAs)

📌 SLA Components in Dynamics 365 CE

SLAs in Dynamics 365 consist of:

  • SLA KPI (Key Performance Indicators): Measures response/resolution times.
  • SLA Items: Define individual conditions and success criteria.
  • Success Actions: Define what happens when SLA is met.
  • Failure Actions: Define what happens when SLA is breached.
  • Warning Actions: Sends notifications before SLA breaches.

📌 Step 2: Create a New SLA

  1. Navigate to: Customer Service Hub → Service Management → SLAs
  2. Click New
  3. Fill in the details:
    • Name: Define an SLA name (e.g., "Premium Support SLA").
    • Entity: Select Case (or another entity if needed).
    • Applicable From: Choose the field that determines SLA start time (e.g., Case Created On).
    • Business Hours: Assign working hours to exclude weekends/holidays.
    • SLA Type: Choose Enhanced SLA for advanced tracking.
  4. Click Save (but don’t activate yet).

📌 Step 3: Create SLA KPI(s)

  1. Navigate to SLA KPIs → Click New
  2. Define KPI details:
    • Name: (e.g., "First Response Time")
    • Entity: Case
    • Applicable From: (e.g., "Case Created On")
    • Field for Success Criteria: (e.g., "First Response Sent")
  3. Save and Close.

📌 Step 4: Add SLA Items

Now, configure the rules and conditions for SLA tracking.

  1. Open your SLA and click + Add SLA Item
  2. Define:
    • Name (e.g., "High Priority Response Time")
    • KPIs: Select SLA KPI (e.g., First Response KPI)
    • Applicable When: Set conditions (e.g., Case Priority = High)
    • Failure Time: (e.g., 2 hours for first response)
    • Warning Time: (e.g., 1.5 hours before failure)

📌 Step 5: Configure Actions (Failure, Warning, Success)

Each SLA item allows defining actions upon success, warning, or failure:

✅ Success Actions (When SLA is met)

  • Update a Case field (e.g., "SLA Status = Met")
  • Notify a supervisor
  • Send confirmation email

⚠️ Warning Actions (Before SLA is breached)

  • Notify an agent to take action
  • Escalate to a manager

❌ Failure Actions (When SLA is breached)

  • Update a Case field (e.g., "SLA Status = Failed")
  • Escalate case priority
  • Assign the case to another team

Save & Close SLA Item.


📌 Step 6: Activate and Apply the SLA

  1. Click Activate the SLA
  2. Set the Default SLA (if required)
  3. Apply SLA on cases automatically or manually.

📌 Step 7: Test & Monitor SLA Performance

  • Go to a Case record and verify the SLA timer.
  • Check SLA KPIs in the timeline.
  • Monitor SLA performance in dashboards and reports.

📌 Advanced Features

🔹 Pause & Resume SLA: Configure SLA pause for cases on hold.
🔹 Multiple SLAs: Assign different SLAs based on case type or customer.
🔹 Power Automate Integration: Trigger advanced notifications and escalations.

Saturday, 28 January 2023

How to get logged in User's Security Roles using Java Script in dynamic CRM 365.

 function GetloggedUser () {

    var roles = Xrm.Utility.getGlobalContext().userSettings.roles; 

    if (roles === null) return false; 

    var hasRole = false;

    roles.forEach(function (item) {

        if (item.name.toLowerCase() === "manager" || item.name.toLowerCase() === " System administrator") {

            hasRole = true;

        }

    }); 

    return hasRole;

}

Monday, 22 June 2020

Android Firebase Push Notification in asp.net C#



using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;

namespace AnroidPushNotification
{
public class AndriodPushNotification
{

public string SendPushNotificationForAndroidSWithoutImage()
{
PushNotificationParameters parameters = new PushNotificationParameters();

parameters.DeviceId = "Token ID";
parameters.ServerKey = "ServerKey ";
parameters.SenderId = "SenderId";
parameters.RequestTimeOut = 20000;
parameters.Title = "TestTitle";
parameters.SoundEnable = "Enabled";
parameters.NotificationEN = "TestEn";
parameters.NotificationAR = "TestAR";
parameters.Message ="testMessage";
string response;
try
{
WebRequest request = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
request.Timeout = parameters.RequestTimeOut;
request.Method = "Post";
request.ContentType = "application/json";
var data = new
{
//ApplicationId = parameters.ApplicationId,
to = parameters.DeviceId,
priority = "high",
content_available = true,
notification = new
{
title = parameters.Title,
sound = parameters.SoundEnable,
messageAR = parameters.NotificationAR,
messageEN = parameters.NotificationEN
}
};
var json = SerializeAndroidWithoutImage(parameters);
//tracingService.Trace("SendPushNotificationForAndroidWithoutImage: json" + json);
Byte[] byteArray = Encoding.UTF8.GetBytes(json);
request.Headers.Add(string.Format("Authorization:key={0}", parameters.ServerKey));
request.Headers.Add(string.Format("Sender: id={0}", parameters.SenderId));
request.ContentLength = byteArray.Length;
// tracingService.Trace("SendPushNotificationForAndroidWithoutImage : ContentLength" + byteArray.Length);

using (Stream dataStream = request.GetRequestStream())
{
dataStream.Write(byteArray, 0, byteArray.Length);
// tracingService.Trace("SendPushNotificationForAndroidWithoutImage:dataStream " + dataStream.Length);

using (WebResponse webResponse = request.GetResponse())
{
using (Stream dataStreamResponse = webResponse.GetResponseStream())
{
using (StreamReader streamReader = new StreamReader(dataStreamResponse))
{
string sResponseFromServer = streamReader.ReadToEnd();
response = sResponseFromServer;
}
}
}


}


}
catch (Exception ex)
{
response = ex.Message;
}
return response;
}
public string SerializeAndroidWithoutImage(PushNotificationParameters parameters)
{
string result = string.Empty;
result = "{\"to\":\"" + parameters.DeviceId
+ "\",\"data\":{\"title\":\"" + parameters.Title
+ "\",\"body\":\"" + parameters.Message
+ "\",\"sound\":\"" + parameters.SoundEnable
+ "\",\"messageAR\":\"" + parameters.NotificationAR
+ "\",\"messageEN\":\"" + parameters.NotificationEN
+ "\"}}";


return result;

}
}
}


Wednesday, 11 September 2019

Dynamic CRM 365 - Option Set cascading Filtering using Java Script.




function lead_Filter_CustomerType_OnLoad()

var customerType = Xrm.Page.getAttribute("inf_customertype").getValue();
  if (customerType == 1)
  {
   Xrm.Page.getControl("inf_leadstatus").removeOption(8); // removeOption use for removing option set value at form load 
   Xrm.Page.getControl("inf_leadstatus").removeOption(9);
   Xrm.Page.getControl("inf_leadstatus").removeOption(10);
   Xrm.Page.getControl("inf_leadstatus").removeOption(10);   
  }
else if(customerType == 2)
 {
   Xrm.Page.getControl("inf_leadstatus").removeOption(1);
   Xrm.Page.getControl("inf_leadstatus").removeOption(2);
   Xrm.Page.getControl("inf_leadstatus").removeOption(3);
   Xrm.Page.getControl("inf_leadstatus").removeOption(4);
   Xrm.Page.getControl("inf_leadstatus").removeOption(5);
   Xrm.Page.getControl("inf_leadstatus").removeOption(6);
   Xrm.Page.getControl("inf_leadstatus").removeOption(7); 
  }
}


function lead_Filter_LeadStatusOnLoad()
{
var leadstatus = Xrm.Page.getAttribute("inf_leadstatus").getValue();
if (leadstatus == 8)
{
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(12); 
}
else if (leadstatus == 9)
{
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(11); 
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
if (leadstatus == 10)
{
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(11);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(12);
}
if (leadstatus == 11)
{
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(1);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(2);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(3);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(4);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(5);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(6);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(7);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(8);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(9);
   Xrm.Page.getControl("inf_leadsubstatus").removeOption(10);

}
}



function lead_Filter_CustomerType_OnChange()
{
  var customerType = Xrm.Page.getAttribute("inf_customertype").getValue();
 
  var optionSet = Xrm.Page.ui.controls.get("inf_leadstatus");
  var optionSetValues = optionSet.getAttribute().getOptions();  
  optionSet.clearOptions();
  if (customerType == 1)
  {
  optionSetValues.forEach(function (element) {
  //using forEach store all option value in eleement
  if (element.value == "1") 
  optionSet.addOption(element);
  // addoption use for display option set value at form .
  if (element.value == "2")
  optionSet.addOption(element);
 
  if (element.value == "3")
  optionSet.addOption(element);
 
  if (element.value == "4") 
  optionSet.addOption(element);
 
  if (element.value == "5")
  optionSet.addOption(element);
   
  if (element.value == "6")
  optionSet.addOption(element);
   
  if (element.value == "7")
  optionSet.addOption(element);
  });
  }
   else if (customerType == 2)
  {
  optionSetValues.forEach(function (element) {
  if (element.value == "8") 
  optionSet.addOption(element);
 
  if (element.value == "9") 
  optionSet.addOption(element);
 
  if (element.value == "10")
  optionSet.addOption(element);
 
   if (element.value == "11") 
  optionSet.addOption(element);
  });
  }

}


function lead_Filter_LeadStatus_onChange()
{
var leadstatus = Xrm.Page.getAttribute("inf_leadstatus").getValue();
 
  var optionSet = Xrm.Page.ui.controls.get("inf_leadsubstatus");
  var optionSetValues = optionSet.getAttribute().getOptions();  
  optionSet.clearOptions();
  if (leadstatus == 8)
  {
  optionSetValues.forEach(function (element) {
  if (element.value == "1") 
  optionSet.addOption(element);
 
  if (element.value == "2")
  optionSet.addOption(element);
 
  if (element.value == "3")
  optionSet.addOption(element);  

  });
  }
   else if (leadstatus == 9)
  {
  optionSetValues.forEach(function (element) {
  if (element.value == "4") 
  optionSet.addOption(element);
 
  if (element.value == "5") 
  optionSet.addOption(element);

  });
  }
 
   else if (leadstatus == 10)
  {
  optionSetValues.forEach(function (element) {
  if (element.value == "6") 
  optionSet.addOption(element);
 
  if (element.value == "7") 
  optionSet.addOption(element);
 
  if (element.value == "8")
  optionSet.addOption(element);
 
   if (element.value == "9") 
  optionSet.addOption(element);
 
    if (element.value == "10") 
  optionSet.addOption(element);
  });
  }
 
   else if (leadstatus == 11)
  {
  optionSetValues.forEach(function (element) {
  if (element.value == "8") 
  optionSet.addOption(element);
 
  if (element.value == "11") 
  optionSet.addOption(element);
 
  if (element.value == "12")
  optionSet.addOption(element);
 
  });
  }

}






How to convert plugin assembly (dll) into base 64 bytes using console application (C#).

 using System; using System.IO; using System.ServiceModel.Description; using Microsoft.Rest; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sd...