Avoid issue of running multiple background workflow processes


Whenever user sets due date on task record, a reminder should go to owner of the task.

Implementation Approach: We will implement this using a workflow with below configuration:

  1. Create a background workflow on task entity.
  2. Set trigger points of workflow as below:
    1. When record is created.
    2. When task due date is updated.
  3. Set workflow logic as below:
    1. Wait until Due Date becomes true (i.e. wait until due date arrives).
    2. On success, send email notification.

Note: In this blog, I have not focused on how workflow is created and how above steps are achieved.

Problem Statement

Above approach will not work properly in below scenario:

  1. User creates task and sets due date as 5 days later.
    1. A background process will be created and will go in wait condition.
  2. User again opens the task created above and updates the due date as 7 days later.
    1. In this case as well, new background process will be created and will go in wait condition.

Now, when actual due date arrives i.e. 7 days after, both of the background processes will be succeeded and 2 email notifications will be sent to the owner. This is incorrect and needs to be fixed.


To solve this issue, I have created a custom workflow assembly which checks active background process count associated with the record and returns the value back in output parameter. So, if we call this custom workflow as a first step in our workflow and if active session count is equals to 0, then we can proceed else we will stop workflow.

This way, at any given point of time, there will be only 1 active session which will be succeeded on actual wait condition success.

I have attached managed solution which contains below 2 components:

  1. Custom Workflow Assembly.
  2. A sample workflow on task entity (in deactivated state) to show an example and how to use it.

Download managed solution here.

How it works



Get lookup field’s data on child form using JavaScript without querying the record

Problem Statement

We come across one of the frequent requirement to populate fields on child record’s form from the lookup field’s data. Whenever user changes the lookup field’s value, the respective information on other fields on the form should be populated from lookup record. Below is an example:

We have an Employee entity and CTC entity. On CTC entity, we have lookup of Employee record. Employee entity contains below fields:

  1. Name
  2. Joining Date
  3. Gender

CTC entity contains below fields:

  1. Total CTC Amount
  2. Employee (Lookup)
  3. Employee’s joining date
  4. Employee Gender

Now the requirement is, on CTC record, when employee is selected, Employee’s joining date and gender should be populated from the employee record.

Old way

Till now, we used to achieve this by registering JavaScript method on change event of Employee field on CTC. Then through JavaScript call, we used to fetch employee record’s data and set the value after getting results.

New way (CRM 2016 onwards)

With latest CRM 2016 release, Microsoft has introduced new methods to access quick view form’s fields using XRM object. So, it helped in bypassing an additional call to the record and directly fetch data from the form itself. Below are the steps to achieve this requirement without making call to the record.

    1. Add quick view form on employee entity and add Joining date and gender field on the form.
    2. On CTC entity form, add quick view form of employee entity.
    3. Add JavaScript event on employee field’s change event and register below method on the same:
function populateFieldsFromEmployeeRecord()
	if(Xrm.page.getAttribute("new_employee").getValue())//new_employee is lookup field on CTC record
		var quickViewControl = Xrm.Page.ui.quickForms.get("");
		if (quickViewControl && quickViewControl.isLoaded())
			var gender = quickViewControl.getControl(0).getAttribute().getValue(); //you can use quickViewControl.getControl(0).getName() method to validate the field's logical name
			var joiningdate = quickViewControl.getControl(1).getAttribute().getValue();

That’s it.

How to remove business process flows from existing records?

Problem Statement

Many times we come to a scenario where clients ask to remove business process flows from the production environments. In such scenarios, there are chances that on the existing records, the business process flows are already set on the records. Hence even if we deactivate the business processes, we still see a yellow ribbon as per below screenshot:


So, how to fix this issue?


  • First of all, we should not directly delete the business processes as clients might ask to reactivate the same and we don’t want to rework on the complex logic we have already implemented.
  • So, to remove above issue while keeping backup of the business process, we will have to follow below steps:
    • Go to Setting > Processes
    • Select the business process flow and deactivate it.
    • Open Business process flow and click on the Save As option from the top ribbon.
    • Delete the old business process flow.
  • After following above steps, you should be able to see that, business process section from existing records is removed and no warnings are shown at the same time, we have backup of the process which we can reactivate in future if needed.

How to insert hyperlink with friendly URL in Email Templates in CRM

Problem Statement

  • Many times we came across the scenario to have links in email templates and make the email template better in presentation aspect with the help of HTML.
  • This blog explains how can you add hyperlink with friendly URL in Email templates.

Business Scenario

  • ‘Adventure Works’ company wants to send email notification to case owner on create of case with below email format.


  • Click here should navigate user to URL stored in Custom URL field of Case entity.
  • We will achieve this requirement with the help of email template.

Note: I have not covered creation of workflows in this blog. I will use workflow on create of case record to send email using below email template.

Steps to create email template

  • Click New. Select Template Type as Case.
  • Go to Settings > Templates > Email Templates


  • Create template body as per below:


Below will be the output:

email output.png
Enter a caption

Select your error notification preferences

  • We have observed that many times when we access CRM environment, somehow we get to see below error notifications. Most of the times these errors are not related to our custom development.


  • So, when we are in meeting, or showing product demo to client, and if such errors occur on the screen, clients will not like it and hence we should always take care of these unwanted and uncontrollable errors.
  • As, these are not our errors, the only thing we can do is that, we can disable these notifications to come up on the screen.
  • Below are the 2 ways in which you can disable these notifications:

Method 1: Ask individual user to set the preferences.

  1. Go to Personal settings from Top Right Setting icon.


  1. Go to Privacy tab and select option ‘Never send an error report to Microsoft about Microsoft Dynamics CRM’.
  2. Click OK.

Method 2: You (CRM Administrator) set preferences on behalf of your users.

  1. Go to Settings > Administration.
  2. Select Privacy Preferences option.
  3. Select setting as below: