D365 – Multi Select Option set JScript Syntax

November 21, 2017 Leave a comment

In this article I am going to provide JScript syntax’s to use in projects.

Refer my previous article on configuring Multi Select Option set fields.

// Read the values
var branches = Xrm.Page.getAttribute(“new_branches”).getValue();
Xrm.Utility.alertDialog(“Branches – ” + branches, null);

// Set the values (i.e., Hyderabad,Chennai)
Xrm.Page.getAttribute(“new_branches”).setValue([100000000, 100000001]);

// Determine if the option is selected
var isCitySelected = Xrm.Page.getAttribute(“new_branches”).getValue().includes(100000000);
Xrm.Utility.alertDialog(“Is City Selected – ” + isCitySelected, null);

// Clear the values

Create a web resource with these syntax’s and map to the form.

JScript - Multi select option set



Set “Created On”,” Created By”, “Modified On”, “Modified By” fields using SDK/Data Import/Plug-in – Dynamics 365

November 18, 2017 Leave a comment

I got an ask from one of my blog followers on how to set “Created On” field of a record, as it defaults to current date.

In this article I am going to explain various ways to set these values.

Override ‘Created On’ using Data Import:

  • Using ‘Data Import’, setting the “Created On” is straight forward and all you need is to add a column “Created On” in your .csv file and import.

Override Created On - Data Import

  • For non-system admin users who import, make sure “Override Created on or Created by…” Privilege is checked in their Security Role.

Override Created On - Privilege

Points to Ponder:

  • Even though the privilege “Override Created on or Created by for records during data import” name suggests overriding “Created by” field but we cannot override “Created by” via Data Import.

Override ‘Created On’ using SDK:

  • Set the “overriddencreatedon” field to the date, which you want your “Created On” date as.
  • Post the execution of code, “Created On” value will be overridden with the Date set in “overriddencreatedon” field and “overriddencreatedon” field will default to todays date.
  • For example, today is “01-01-2017” and you want the “Created On” as “01-01-2016”
    • Set “overriddencreatedon” to “01-01-2016”
    • After code execution, “Created On” will set to “01-01-2016” and “overriddencreatedon” will be today (i.e., 01-01-2017)

Sample code:

Entity contact = new Entity(“contact”);
contact[“firstname”] = “Contact Migrated”;
contact[“overriddencreatedon“] = new DateTime(2016, 01, 01);

Override “Created On”,” Created By”,” Modified On”,” Modified By” using Plug-in:

  • To Override the fields, we need to go for plug-in approach.
  • Register a “PreOperationCreate” plug-in and set the fields.

Override Created On - Plug-in step

Plug-in Code:

public void Execute(IServiceProvider serviceProvider){
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains(“Target”) && context.InputParameters[“Target”] is Entity)
// Obtain the target entity from the input parameters.
Entity TargetEntity = (Entity)context.InputParameters[“Target”];

// Set date in Past
TargetEntity[“createdon”] = new DateTime(2016, 01, 01);
TargetEntity[“modifiedon”] = new DateTime(2016, 01, 01);
// Set the GUID of non-calling user
TargetEntity[“createdby”] = new EntityReference(“systemuser”, new Guid(“5BB6EF5F-6BCC-E711-A831-000D3A1BE051”));
TargetEntity[“modifiedby”] = new EntityReference(“systemuser”, new Guid(“5BB6EF5F-6BCC-E711-A831-000D3A1BE051”));

  • Once this plug-in executes, values will get overridden with the passed values.

Override Created On - Plug-in

Points to Ponder:

  • As you would have noticed, it requires a plug-in to set the ”Created By”,” Modified On”,” Modified By” fields which is an overhead.
  • But this approach is extremely useful in “Data Migration” as this is common ask while migrating historical client data.
  • Have the plug-in step enabled during “Data Migration” and deactivate post migration.


What’s new for Developers/Admins/End Users – Dynamics 365 – v 9.0

With July 2017 update (v 9.0) there is a great set of new features introduced.

Now onward, the apps that make up the customer relationship management (CRM) portion of Dynamics 365 are referred to as “Customer Engagement” and include Sales, Customer Service, Field Service, Project Service Automation, and their related services.

In this article I am going to touch base few new features at a high level. I will be covering each feature in detailed in follow up articles.

UX Enhancements:

  • Removal of unneeded white space on forms and dashboards.
  • On forms, long text labels and values are wrapped. Admins can control word wrap through system level settings.

Text wrapping

  • The color of a sub-grid header can be customized at the form level
    • While adding sub grid to a form, now we have an option to set ‘Panel Header Color’

Sub grid Header Color

  • Themes – There are now three new standard themes to choose from.


  • Email editor control has been updated with rich editing capability.
  • Enhancements to ‘Sitemap Designer’ and ‘View Designer’

Advanced Find:

  • Advanced Find has got ‘Not In’ query option using “Does not contain data” operator.
  • Refer my previous article

Advanced Find - Not IN

Activity management:

  • New Quick Create forms have been introduced for Task, Phone Call, and Appointment with customization capabilities.

Dynamics 365 mobile app:

  • The new mobile app is built on the new Unified Interface, which provides key accessibility and responsive design benefits.
  • If you can add iFrames and web resources in forms and dashboards in a Dynamics 365 (online) web app, they will be enabled in Dynamics 365 for phones as well, if you check the box to enable iFrames and web resources for phones.

Virtual Entities:

  • A virtual entity is a custom entity in Dynamics 365 (online) that retrieves data at runtime from an external data source.
  • Records based on virtual entities are available from all Dynamics 365 (online) clients, including custom applications developed using the Dynamics 365 SDK.
  • Several options, such as Access Teams, Queues, and Quick Create, aren’t available with virtual entities.
  • Virtual entities are organization owned.
  • All virtual entities are read-only.
  • Existing entities cannot be converted to virtual entities.
  • Virtual entities don’t support auditing.
  • Virtual entity fields can’t be used in rollups or calculated fields.

MultiSelect option set:

D365 - Multiple Optionset - on form

Web resource dependencies:

  • In this release, you can now specify web resources during customization that will be used at run-time to include dependencies. This makes it easier to ensure that HTML, JavaScript resources, and all dependent resources are loaded appropriately.

Web resource localization:

  • This release includes support for a new resource type, RESX, which is an XML-based file format that supports comments associated with key+value translation pairs and is supported in Visual Studio.
  • You can associate RESX web resources with any JavaScript web resource that uses them so that you can use a new client-side API to access localized strings at run time.

Vector Image web resources:

  • Use vector images for any icon presented in the application.
  • The advantage of vector images over other image web resources is that they scale.
  • You can define one vector image and re-use it rather than provide multiple sizes of images.
  • You can use this web resource to define a single icon for an entity rather different sized images.

Web API improvements:

  • GrantAccess, ModifyAccess, and RetrieveSharedPrincipalsAndAccess messages are now available using the Web API.

Client API Enhancements:

  • Xrm.Page.context is deprecated in this release and will be replaced by Xrm.Utility.getGlobalContext
  • method’s ‘saveOptions’ to include a new value called SaveMode to let the onSave event handlers know why the save is happening.

Grid Click event – Override the default open behavior of data rows in an entity-bound grid:

  • As an OOB grid behavior, on double click of data row or clicking hyper link in Data row will open the entity record.
  • With this release, we can now override the default behavior to define your own custom behavior.
  • Create a command definition for an entity with Mscrm.OpenRecordItem as the value of the Id attribute (<CommandDefinition> (RibbonDiffXml)), and define custom action for the command <Actions> (RibbonDiffXml)
  • System will look for this command Id for an entity when you try to open a record from the entity-bound grid, and if present, will execute the custom action instead of opening the entity record (default behavior).

Customer Service Hub:

  • The Customer Service Hub (called Interactive Service Hub in earlier releases) has been rebuilt on the new Unified Interface as a stand-alone application.

Business process flows enhancements:

  • Business Process flow is now an entity and you can create custom views.
  • Business Process entities can now be made available on the site map

Useful articles:


Categories: Dynamics 365 Tags: ,

Query using ‘Not In’ filter – Advanced Find – Dynamics 365 – V 9.0

October 7, 2017 1 comment

In the previous versions of CRM, there is no option in Advanced Find, to query all ‘Case’ records that do not have a related task, as we don’t have option to execute ‘Outer Join’ (i.e., Not in).

In V9.0 release, a new ‘Does not contain data‘ option added to ‘Advanced Find’ to filter ‘Not In’ records.

Let’s get started to fetch all the ‘Accounts’ which does not have any associated ‘Contacts’

  • Open ‘Advanced Find’
  • Select ‘Account’ entity and from the Related entities choose OOB ‘Contacts(Company Name)’ relationship.
  • Choose ‘Does Not Contain Data’ from filter option.

Advanced Find - Not IN

  • Fetch XML will be as below

Fetch XML - Not IN


Dynamics 365 – V9.0 – Multiselect option sets walk through

October 7, 2017 2 comments

In this article I am going to walk through the new field type “Multiselect Option set” from V9.0.

As the name suggests, “Multiselect Option set” will allow User to choose multiple choices.

In this walk through, I am going add a new ‘Multiselect Option Set’ called ‘Branches’ on ‘Account’ entity to capture the Account presence across the country.

  • Create a new field of type ‘Multiselect Option Set’ to the Account entity. I chose existing Global option set ‘City’ for this example. Create new Options, if you dont want to go with Global option set.

D365 - Multiple Optionset

  • Add this field on ‘Account’ main form and Publish the customizations.
  • Open any of the existing Account record and Select the Branches.

D365 - Multiple Optionset - on form

  • Add ‘Branches’ field to the view

D365 - Multiple Optionset - on view

  • Search in ‘Advanced Find’

D365 - Multiple Optionset - Adv Find 1

  • Fetchxml would form as below

D365 - Multiple Optionset - Adv Find Fectchxml

Key Points:

  • Multi-select option sets are available for Unified Interface and the web client.
  • Multi-select option sets are available for the following form types: Main, Quick Create, and Quick View.
  • Multi-select option sets won’t be supported on legacy forms.


D365 July Updates – Multi select option set and Virtual entity

September 10, 2017 Leave a comment

With July updates Dynamics 365 introduced few new features. I am going to touch base:

Virtual Entity:

  • Virtual entities replace previous client-side and server-side approaches to integrating external data, which required customized code and suffered from numerous limitations, including imperfect integration, data duplication, or extensive commitment of development resources.
  • Virtual entities are stored in CRM with an internal metadata flag on the entity marked as virtual, which tells the system not to put a schema in the database. Virtual entities are organization owned, there isn’t any CRM role level security for virtual entities. Each virtual entity points to a row from the data source
  • Refer this Article

Multi-select option set:

  • This is long awaiting feature. Limitation of existing Option set was we could select only one option. With the advent of new control we can select multiple options.
  • Select options stored in a field separated by ;
  • Features of the new Multi-Select option set include:
    • A new AttributeType: MultiSelect Option Set introduced.
    • We can add control to forms, views, and quick create forms, and read-only and editable grids
    • Can add up to 150 values available for selection
    • ‘Select All’ and ‘Clear selection’ feature
    • Supported in Advanced Find and FetchXML queries
  • Refer for more details.



Azure Deployment Slots – Deploy and Swap

September 10, 2017 Leave a comment

Assume that you have your live application deployed on Azure running and you must deploy a hot fix.

The option you got is, you might want to take your application down for some time till your hot fix deployed.

How about you deploy the hot fix with no downtime, the answer is Azure “Deployment Slots”.

Create a Deployment Slot:

To use ‘Deployment Slots’, make sure you are running with Standard or Premium Azure Service Plan before adding a slot

  • Connect to Azure subscription and open your existing ‘App Service’
  • Under ‘DEPLOYMENT’ section, select ‘Deployment Slots’ and click on “Add Slot”

Azure - Deployment Slot

  • In the next screen, provide Slot name and choose ‘Configuration Source’. I gave my Slot name ‘Staging’ and in the ‘Configuration Source’:
    • If you choose your existing ‘App service’ all the settings including ‘Application Settings/Diagnostic Settings/…’ will be copied to this slot
    • Or you can choose ‘Don’t clone configuration….’ Option, if you want your slot to be clean and no carry over settings.

Deployment Slot - Add

  • Click ‘Ok’
  • After few seconds, you would get notification that your slot is ready
  • Once slot setup completed, your main App name will come as prefix of your slot (Ex: If ABC is my web app; my Slot name is ABC-staging)

Deployment Slot - Created

Publish Website to Slot:

  • Use Visual studio “Publish Web” option

Deploy - Connect Azure App Service

  • Select “Microsoft Azure App Service” and choose your main “App Service” and “Deployment Slots -> {Slot}”

Deploy - Slot

  • Click “Publish”
  • After publishing, your slot would work as any other Web App. You can give the slot URL to test to run BVT

Deployment Slot - Open Staging

Swap Slot:

  • Once you feel your slot is fine and can be promoted as main App
  • Click on ‘Swap’

Swap - 1

  • Select ‘Source’ and ‘Destination’
    • Main Web App would always represent as “production”
    • “Staging’ is the name of your slot

Swap - 2.PNG

  • Click Ok
  • It would take couple of minutes to complete Swap
  • Once Swap completes, end users who are accessing would start getting new build with virtually no down time.

Useful points:

  • If any errors are identified in production after a slot swap, roll the slots back to their pre-swap states by swapping the same two slots immediately
  • You can check your available ‘Deployment Slots’ by opening your Service Plans.

Check you available Slots.PNG