Insert dynamic values in Email Templates from Custom Entities

As a Microsoft Dynamics CRM developer some times you need to work with Email Templates. Basically email templates save time when creating multiple email messages. Email templates contain pre defined data of CRM records, so we don’t have to reenter the same information again. Specifying dynamic values from out of the box entities is pretty simple but there are some instances when we might want to add dynamic values from custom entities. To which we don’t have any straight forward approach in CRM as we cannot add custom entity in email template.

So here is the requirement:

Send an email upon successful creation of Patient record using email template.
Registration email should contain the following format and values from Patient Record.

Dear <Patient Name>,

Thank you for visiting our Hospital.
We would like to inform you that your registration is successful, Please find the details below

<Type : Single Line of Text>
Patient Name : <Name of the patient>
Patient ID : <Patient Business ID>

<Type : Lookup>
Hospital : <Hospital ID>
Doctor : <Patient ID>

<Type : Date Time>
Registration Date with Time: <Registration Date>
Date Of Birth with Time : <Date Of Birth>

<Type : Currency>
Treatment Cost : <Treatment Cost>

<Type : Decimal Number>
Consultation Fee : <Consultation Fee>

<Type : Floating Point Number>
Estimated Amount : <Estimated Amount>

<Type : Multi Line of Text>
Address : <Address >
Patient Details : <Patient Details>


<Type : Multi Select Option Set>
Symptoms : <Type : Option Set>

<Type : Option Set>
Gender : <Patient Gender>
Patient Status : <Patient Status>
Status : 

<Type : Two Option set>
Hospitalization Required : <Hospitalization Required>
Show Patient Details : <Show Patient Details>

Best Regards,
Hospital Management.

Step – 1:
First create an Email Template of type “Global” by following below navigation Settings < Templates and then clicking Email templates and Click on ” New” button then Select Template Type “Global”  and click on “OK”.

Global Email Template-1

Give a proper name like “Patient Registration Template” as shown below

Patient Registration Email Template

Step – 2:
The below table gives the syntax for inserting dynamic values from Custom entities

S.No Field Type Syntax Example
1 Single Line of Text {!EntityLogicalName:FieldLogicalName;} {!new_patient:new_patientname;} or {!new_patient:new_patientbusinessid;}
2 Lookup {!EntityLogicalName:FieldLogicalName/@name;} {!new_patient:new_hospitalid/@name;} or {!new_patient:new_doctorid/@name;}
3 Date {!EntityLogicalName:FieldLogicalName/@date;} {!new_patient:createdon/@date;} or {!new_patient:new_dateofbirth/@date;}
4 Time {!EntityLogicalName:FieldLogicalName/@time;} {!new_patient:createdon/@time;} or {!new_patient:new_dateofbirth/@time;}
5 Currency {!EntityLogicalName:FieldLogicalName;} {!new_patient:new_treatmentcost;}
6 Decimal Number {!EntityLogicalName:FieldLogicalName;} {!new_patient:new_consultationfee;}
7 Floating Number {!EntityLogicalName:FieldLogicalName;} {!new_patient:new_estimatedamount;}
8 Multiline of Text {!EntityLogicalName:FieldLogicalName;} {!new_patient:new_address;} or {!new_patient:new_patientdetails;}
9 Multi Select Option Set {!EntityLogicalName:FieldLogicalName/@name;} {!new_patient:new_symptoms/@name;}
10 Option Set {!EntityLogicalName:FieldLogicalName/@name;} {!new_patient:new_gender/@name;}
11 Two Options {!EntityLogicalName:FieldLogicalName/@name;} {!new_patient:new_hospitalizationrequired/@name;} or {!new_patient:new_showpatientdetails/@name;}

Step – 3: Open the email template and place the required details in email body like below

PatientDetails1

Save the email template and you will see the updated email template like shown below

PatientDetails2

Step -4 : Create a workflow on Patient entity with create event and select the send the email step, associate the email template created above as shown below

PatientRegistrationEmailWorkflow-1

Click on Set Properties and to see the below window and provide details in From/To and select “Patient Registration Email Template” and click on save and close and finally Activate the workflow

PatientRegistrationEmailWorkflow-2

Step – 5: Create a patient record with relevant details as shown below

PatientRecordDetails

Step – 6: Go to Advanced find and search for Email Messages and click on results, You will see list of Email messages created by the system and select the relevant one and open

EmailMessages-1

Here you go, your Patient Registration Email contains all the details which you have mentioned on the email template…!!!

EmailMessages-2

Define different types of Input and Output arguments for custom workflow activity

As a MS Dynamics CRM Developer there are certain situations where you need to pass some of the entity field values as Input arguments to a Custom Workflow activity and some cases you may require to get some of the code execution results as Output arguments from a custom workflow activity.

In order to accomplish this you definitely need to have an idea on the Syntax of the Input and Output arguments for different types of fields.

Here i considered an entity called Patient which is having different types of fields and those are given below
1. Patient Name : String
2. Date Of Birth : Date and Time
3. Hospital : Lookup (to an entity called Hospital)
4. Patient Status : Option Set
5. Hospitalization Required : Two Option Set
6. Patient Age : Whole Number
7. Consultation Fee : Decimal Number
8. Estimated Amount : Floating Point Number
9. Treatment Cost : Currency
10. Patient Id : String

Types of arguments

  1. Input : Entity field value can be passed to Custom workflow activity
  2. Output : Execution result (if any) can be passed as output from Custom workflow activity
  3. Input/Output : It can be used as both Input and Output

The following Custom Workflow Activity code will explains how to declare Input and Output arguments.

using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using System.Activities;

namespace InputOutputParameters
{
    public class InputOutputParameters : CodeActivity
    {
        //Data Type : String 
        [Input("patientname")]
        [RequiredArgument]
        public InArgument<string> PatientName { get; set; }

        //Data Type : Date and Time
        [Input("dateofbirth")]
        [RequiredArgument]
        public InArgument DateOfBirth { get; set; }

        //Data Type : Lookup
        [Input("hospital")]
        [ReferenceTarget("new_hospital")]
        [RequiredArgument]
        public InArgument Hospital { get; set; }

        //Data Type : Option Set
        [Input("patientstatus")]
        [RequiredArgument]
        [AttributeTarget("new_patient", "statuscode")]
        public InArgument PatientStatus { get; set; }

        //Data Type : Two Option Set
        [Input("hospitalizationrequired")]
        [RequiredArgument]
        public InArgument<bool> HospitalizationRequired { get; set; }

        //Data Type : Whole Number
        [Input("patientage")]
        [RequiredArgument]
        public InArgument<int> PatientAge { get; set; }

        //Data Type : Decimal Number
        [Input("consultationfee")]
        [RequiredArgument]
        public InArgument<decimal> ConsultationFee { get; set; }

        //Data Type : Floating Point Number
        [Input("estimatedamount")]
        [RequiredArgument]
        public InArgument<decimal> EstimatedAmount { get; set; }

        //Data Type : Currency
        [Input("treatmentcost")]
        [RequiredArgument]
        public InArgument TreatmentCost { get; set; }

        //Data Type : String
        [Output("showpatientdetails")]
        public OutArgument<string> ShowPatientDetails { get; set; }


        //Data Type : String (Can be used as Input/Output)
        [Input("patientinput")]
        [Output("patientoutput")]
        [RequiredArgument]
        public InOutArgument<string> PatientInOut { get; set; }


        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                IWorkflowContext workflowContext = context.GetExtension();
                IOrganizationServiceFactory serviceFactory = context.GetExtension();
                IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.UserId);
                ITracingService tracingService = context.GetExtension();

                tracingService.Trace("Patient Details using input and output parameters Workflow Started.");
                var patientName = PatientName.Get(context);
                var dateOfBirth = DateOfBirth.Get(context);
                var hospital = Hospital.Get(context)?.Name;
                var patientStatus = PatientStatus.Get(context).Value;
                var hospitalizationRequired = HospitalizationRequired.Get(context);
                var patientAge = PatientAge.Get(context);
                var consultationFee = ConsultationFee.Get(context);
                var estimatedAmount = EstimatedAmount.Get(context);
                var treatmentCost = TreatmentCost.Get(context).Value;
                var patientId = PatientInOut.Get(context);
                tracingService.Trace($"Patient Name : {patientName}, Date Of Birth : {dateOfBirth}, Hospital : {hospital}, Patient Status : {patientStatus}, Hospitalization Required: {hospitalizationRequired}, Patient Age: {patientAge}, Consultation Fee : {consultationFee}, Estimated Amount : {estimatedAmount}, Treatment Cost : {treatmentCost}, Patient ID : {patientId}");
                var patientDetails = $"Patient Name : {patientName}, Date Of Birth : {dateOfBirth}, Hospital : {hospital}, Patient Status : {patientStatus}, Hospitalization Required: {hospitalizationRequired}, Patient Age: {patientAge}, Consultation Fee : {consultationFee}, Estimated Amount : {estimatedAmount}, Treatment Cost : {treatmentCost}, Patient ID : {patientId}";
                PatientInOut.Set(context, PatientInOut.ToString());
                ShowPatientDetails.Set(context, patientDetails);
                tracingService.Trace("Patient Details using input and output parameters Workflow Ended.");
            }
            catch(Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
            }
        }
    }

 

The below screen shot will show you the representation of the Input arguments once after you successfully build and deploy the above custom workflow code activity.

Input_Output_Parameters

The most used JavaScript Methods for Dynamics CRM v9.x

Here’s a quick reference guide covering Microsoft Dynamics CRM syntax for common java script requirements for v9.x.

Most of the examples are provided as functions that you can easily test in the On Load and On Save by generating form Context from execution Context.

============================================================
//Execute all On Load events here

function OnLoad(executionContext) {
try {
//Get the form context
var formContext = executionContext.getFormContext();
//Sample code for On Load Event
Xrm.Utility.alertDialog("This is an alert for On Load Event.");
}
catch (e) {
Xrm.Utility.alertDialog(e.message);
}
}

Continue reading “The most used JavaScript Methods for Dynamics CRM v9.x”

Download Dynamics CRM Tools for v9.x

Steps to be followed:

  1. Go to Windows, Search for “Windows Power Shell” and Open it. (Shown below)

Windows PowerShell

2. Navigate to the folder where you want to download the tools, for example if you want to download in a D365Tools folder in  C drive, Type  cd D365Tools\ (Shown Below)

Windows PowerShell

3. Copy  and paste  the following Power Shell script in to the Power Shell window and Press Enter. (Shown Below)

$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = ".\nuget.exe"
Remove-Item .\Tools -Force -Recurse -ErrorAction Ignore
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose

##
##Download Plugin Registration Tool
##
./nuget install Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool -O .\Tools
md .\Tools\PluginRegistration
$prtFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.'}
move .\Tools\$prtFolder\tools\*.* .\Tools\PluginRegistration
Remove-Item .\Tools\$prtFolder -Force -Recurse

##
##Download CoreTools
##
./nuget install Microsoft.CrmSdk.CoreTools -O .\Tools
md .\Tools\CoreTools
$coreToolsFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.CoreTools.'}
move .\Tools\$coreToolsFolder\content\bin\coretools\*.* .\Tools\CoreTools
Remove-Item .\Tools\$coreToolsFolder -Force -Recurse

##
##Download Configuration Migration
##
./nuget install Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf -O .\Tools
md .\Tools\ConfigurationMigration
$configMigFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf.'}
move .\Tools\$configMigFolder\tools\*.* .\Tools\ConfigurationMigration
Remove-Item .\Tools\$configMigFolder -Force -Recurse

##
##Download Package Deployer 
##
./nuget install Microsoft.CrmSdk.XrmTooling.PackageDeployment.WPF -O .\Tools
md .\Tools\PackageDeployment
$pdFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PackageDeployment.Wpf.'}
move .\Tools\$pdFolder\tools\*.* .\Tools\PackageDeployment
Remove-Item .\Tools\$pdFolder -Force -Recurse

##
##Download Package Deployer PowerShell module
##
./nuget install Microsoft.CrmSdk.XrmTooling.PackageDeployment.PowerShell -O .\Tools
$pdPoshFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PackageDeployment.PowerShell.'}
move .\Tools\$pdPoshFolder\tools\*.* .\Tools\PackageDeployment.PowerShell
Remove-Item .\Tools\$pdPoshFolder -Force -Recurse

##
##Remove NuGet.exe
##
Remove-Item nuget.exe

Windows PowerShell

4. You will find the Tools in the folder C:\D365Tools\Tools (The folder you mentioned before)

5. To get the latest version of the tools, Repeat the same steps.

The most used code snippets in Dynamics365

Microsoft Dynamics 365 (on premises) Update 8.2.4

INTRODUCTION
Microsoft Dynamics 365 (online and on-premises) Update 8.2.4 is now available. This article describes the hotfixes and updates that are included in Service Update 8.2.4.

MORE INFORMATION
Update package Version number
Microsoft Dynamics 365 (on premises) Update 8.2.4 8.2.4.6

To determine whether your organization had this update applied, check your Microsoft Dynamics CRM Online version number. Click the gear icon in the upper-right corner, and then click About.

Update information
Microsoft Dynamics 365 (on-premises) Update 2.4 is now available.

The following file is available for download from the Microsoft Download Center:

Download the Microsoft Dynamics 365 (online and on-premises) Update 2.4 package now.

Microsoft Dynamics 365 (on premises) Update 2.4 resolves the following issue:

Performance Improvements
The following list details issues whose resolutions improve the speed or functionality of Dynamics.

  • Incremental system-wide performance improvements have been made in this update.

Unexpected Behavior
The following list details issues whose resolutions correct actions performed in Dynamics that do not work as intended.

  • After running a search in the Quick Find Search field, and then deleting the field’s value, no results were displayed, when instead the full list of files should be displayed.
  • OOB resources were displayed in English regardless of the language setting used.
  • Selecting the “Access it here” link resulted in a blank page opening instead of ISH being launched.
  • Copied read-only values were stored twice into the clipboard and resulted in a duplicated value when pasted.

Repaired Functionality

The following list details issues whose resolutions repair items in Dynamics that are not functioning.

  • Update 72 for Google Chrome causes file names to append characters to the filename that prevent the file from being opened.
  • Contacts synced from CRM online to Outlook using server-side synchronization displayed an email address in place of the first and last name.
  • The routing rule set sequence contained duplicates, and rule items could not be moved up and down when the sort arrow was clicked too frequently.
  • Buttons intermittently stopped working, requiring the user to refresh the page to restore functionality.
  • The regarding field was not updated when multiple users tracked the same email.
    Searching for queue items returned no results.
  • Meeting attachments could not be opened after downloading them.
  • The Lookup control did not load when a user attempted to open it after it was already loaded once successfully and then closed.
  • Searches could not be performed when using the KB Associated view.
  • The To field was blank in the email window that appeared when the “Email Article” link was selected in an article associated with a form.
  • Charts did not render for views with filter criteria.
  • The scroll bar in the Rule Criteria section of rule item records became blocked when any routing rule sets were enabled.
  • Images wider than 610px were not fully displayed and were not scrollable.
    Imported managed solutions containing OOB TBX could not be deleted.
    The available regarding records changed continuously each time an email was selected (only opportunities may be shown, then opportunities and projects, and so on).
  • Server-side synchronization did not reopen tasks in Outlook when the tasks were reopened in CRM.
  • The Dynamics add-in could not render webpages.
  • Outlook with CRM could not be configured.
  • In a complex hierarchy of subjects viewed in ISH via the Subject Tree Control, a node vanished from view when one or more nodes were expanded.
  • Appointments tracked using Mail app were duplicated when the “Track Appointments from Non-Organizers” setting was enabled.
  • The Global Object ID field was empty when tracking meetings/appointments in Outlook Web Access using the Mail app.
  • A referenced entity was deleted when a queue item was deleted.
    The current Japanese era was displayed when a new Japanese era should have displayed.
  • The regarding of Email and Custom activities were not updated to be the Master Case after a case merge took place.
  • Emails were automatically promoted when the email queue was configured to promote all emails.
  • The Option Set field could not be set as Required on Dynamics 365 for Tablets.
    Updates to Appointments set entirely within the past unintentionally sends meeting invites/cancellations to attendees.
  • A workflow that triggers after creating new Contact on Account entities intermittently failed.
  • The CRM app for Outlook page timed out for customers with 2,000 enabled users.
    Messages were missing localization for users lacking permission to create leads and contacts.
  • No more than four attachments could display in emails’ attachment grid.
  • The header was missing from the “Record Creation and Update Rule Item”.
  • Users were redirected to the Expresso app page when attempting to use the Dynamics 365 UWP app (Windows 10 app) on a Win10 phone device.
  • Child processes could not be created through custom entities.
  • Appointments containing Korean characters could not be manually tracked via the CRM Outlook client.
  • The camera would not open for the barcode scanner, and the scanner’s Save button was grayed out.
  • KB articles could not be searched in CRM dashboards.
  • Error Messages, Exceptions, and Failures
  • The following list details issues whose resolutions correct actions that produce errors, unhandled exceptions, or system or component failures.
  • Task items failed when an object reference was not set to an object instance.
  • An exception occurred when editing or exporting apps.
  • An error occurred when creating a holiday schedule record with dates that coincided with the change to Daylight Savings time.
  • An error occurred when branching the condition on editing and removing an else branch.
  • An error occurred when opening a record if Social Insights was in the form.
  • Importing the Currency Excel file failed with an error.
  • An error occurred when opening Service activities from an SLA Associated view.
  • An error occurred when exporting order products.
  • An error occurred when importing reports.
  • Emails with attachments failed to send.
  • An error occurred when editing rollup calculations for the Rating field.

What is CRM ?

What is CRM?

CRM stands for Customer Relationship Management

An organizational practice implemented to synchronize all processes systematically  there by, making it is to fulfil customer requirements.

A technology & system that sustains sales, marketing & customer service activities. It is designed to capture & interpret customer data, both structured & unstructured, & to sustain the management of the business side of customer related operations. CRM technology automates processes & workflows and helps organize & interpret data to support a company in engaging its customers more effectively.

CRM

CRM2

Benifits of CRM:

  • Better Data Organization
  • Enhanced Communication
  • Shared Information
  • Less Hard Work
  • Vivid Clarity
  • Great Control
  • High Productivity
  • Business Expansion
  • Less Functional Cost…etc

CRMBenifits1.png

CRMBenefits2

CRM Overview – 1

CRM Overview – 2

Create your website at WordPress.com
Get started