Archive for the ‘Dynamics 365’ Category

Dynamics Portal Issue – Unable to submit Entity Form

February 17, 2018 Leave a comment

Recently we encountered a strange issue in our Dynamics Portal SaaS variant.

We got a requirement to allow Portal users to create ‘Custom Activity’ records from Portal.

To achieve this, we created an Entity form for the Custom Activity with mode set to ‘Insert’ and configured Web Template.

Portal - Entity Form


  • After configuring Entity Form, Page Template and Web Template, we could not save the record from Portal.
  • Up on ‘Submit’ button click on Create form, there was no server post back.
  • On browser console, “Unable to set property ‘isvalid’ of undefined or null reference” exception has been logged.

Portal - Web Template Error

Reason and Fix:

  • Issue was due to the additional character in ‘Web Template’ Source HTML content (refer below highlighted) and correcting the HTML fixed the issue.

Portal - Web Template



Dynamics Portals – Execute FetchXML and Parse the results – Liquid script

January 22, 2018 Leave a comment

In one of our Portal requirements, we had to build custom screen (i.e., Web Template) and retrieve the results from Dynamics 365 and bind to grid.

In this article, I am going to detail the steps to Execute FetchXML based on conditions and read the results.

As we know that Dynamics portals use Liquid to add dynamic content to pages, lets prepare the Liquid.

High level design:

  • Liquid executes only on the page load, hence create a new Web Template (will be called only in background) and add the Liquid in it.
    • Imp Points:
      • In the web Template where you copy your Liquid to, specify the ‘MIME Type’ as ‘application/json’WT_Resolved Cases
        • You need to uncheck, below property in the ‘Page Template’ associated with the Liquid ‘Web Template’.


  • From my Search screen web template, on change of Dropdown, I will call the above Web Template by passing selected the view as Query string.
  • Up on calling the background template, it executes the Liquid and return the results in Json collection
  • Capture the collection and render the results in table.

Liquid to fetch Cases:

In below liquid, I am reading the query string parameter ‘V‘.

  • If ‘V’=0, Prepare ‘Open Case’ filter
  • If ‘V’=1, Prepare ‘Resolved Case’ filter
{% fetchxml cases %}
<entity name=”incident”>
<attribute name=”incidentid”/> <attribute name=”title”/> <attribute name=”createdon”/> <attribute name=”casetypecode”/> <attribute name=”ticketnumber”/> <attribute name=”subjectid”/> <attribute name=”caseorigincode”/> <attribute name=”customerid”/> <attribute name=”statuscode”/> <attribute name=”statecode”/> <order descending=”true” attribute=”createdon”/>
<filter type=”and”>
{% if request.params[‘V‘] == 0 %}
<condition attribute=”statecode” value=”0″ operator=”eq”/>
{% endif %}
{% if request.params[‘V’] == 1 %}
<condition attribute=”statecode” value=”1″ operator=”eq”/>
{% endif %}
{% endfetchxml %}
{ “totalcount”: {{ cases.results.total_record_count }},
“morerecords”: {{ cases.results.more_records }},
“page”: {{ request.params[‘page’] | default: 0 }},
{% for item in cases.results.entities %} {
“incidentid”: “{{ item.incidentid }}”,
“title”: “{{ item.title }}”,
“statuscode”:”{{ item.statuscode.label }}”,
“createdon”:”{{ item.createdon }}”,
“subjectid”:”{{ }}”,
“customerid”:”{{ }}”
}{% unless forloop.last %},{% endunless %} {% endfor %}
] }

Liquid’s Field Parsing Syntax:

If you notice, I have used {% for item in cases.results.entities %} to loop through the FetchXML results.

  • To read a Look up field text, {{ }}
  • To read a Option set Label, {{ item.statuscode.label }}


Organization Insights – Dynamics 365

December 4, 2017 1 comment

What if your customer ask you to provide a report on the No of Active Users,Licenses, Most used entities etc. The answer is “Organization Insights” solution.

Organization Insights for Dynamics 365 (online) provides usage metrics for your Dynamics 365 organization, and tools to help you track and monitor the performance and support issues.

Steps to download and install:

  • Open the browser and login to your Dynamics 365 instance
  • Download the “Organization Insights” solution by click here

Organization Insights 1


Organization Insights 2

  • Click “Agree” and you will be redirected to Dynamics 365 Admin Center “Manage Solutions” page.

Organization Insights 3

  • Give it sometime to get the solution installed
  • After the solution installation navigate to your application (Settings -> Organization Insights)

Organization Insights 4

Organization insights provide below information once you installed:

Organization Insights 5

  • Active Usage Dashboard
    • Provide the details of
      • No of Dynamics 365 users
      • No of licenses are in use
      • List of custom entities that are used most frequently
    • Data in Dashboard updates every hour
  • System Jobs Dashboard
    • Will help us to monitor and troubleshoot workflows
    • Data in Dashboard updates every hour
  • Plug-ins Dashboard 
    • Will help us to monitor and troubleshoot plug-ins
    • Data in Dashboard updates every hour
  • Storage Dashboard
    • Provides a look at storage used by your tenant and instances
    • Data in Dashboard updates every day

Organization Insights - Data Storage

  • API Call Statics Dashboard
    • Will help us to to monitor and troubleshoot API calls.
    • Useful if you have any 3rd party system pull or push the data in to CRM.
    • Data in Dashboard updates every hour

Organization Insights 6

  • Mailbox Usage Dashboard
    • Will help us to monitor email mailbox usage like No of mail boxes, Active email server profiles etc.
  • Download Dashboard
    • Allow us to download the data selected for the date range in an Excel spreadsheet.
    • It provide details like: Most Used OOB and Custom Entities, Most Active Users Performing Operations (i.e., Retrieve/Retrieve Multiple/CRUD operations)

OData Support:

  • Organization Insights supports retrieving chart data through the Web API.

Refer below article for more info:


Manage your Instance Storage – Dynamics 365

December 4, 2017 Leave a comment

In this article I am detailing on

  • How to check the amount of storage organization is using
  • How to increase/purchase Additional storage
  • ways to reduce the amount of storage space

Storage limit depends on the type of subscription you purchase initially. For 30 days trail you would get 5 GB of storage. If you are run out of storage, you can add more.

Monitor the storage:

To monitor the storage consumption

Organization - Total Storage Used

Alternatively you can install “Organization Insights” solution to your Dynamics 365 and monitor the storage in detail.

Refer my article to know more about Organization Insights

Organization Insights - Data Storage

Increase/Purchase Additional storage:

To add additional storage

  • Login to your O365 Account’s Admin Center
  • Billing -> Purchase services

Admin Center - Purchase services

  • Under “Add-on subscriptions” choose “Dynamics 365 – Additional Database Storage”
    • Note: This is not available if you are on 30 days trail subscription.

Reduce the amount of storage space:

We can reduce the data storage by deleting certain categories of data as the need arises, or you can set up bulk deletion jobs to reoccur at set intervals.

A particularly important note is delete the data only if you are sure that it is no longer needed as you cannot get back the deleted data.

Below are the ways to reduce/free the data storage:

  • Delete bulk email and workflow instances using a bulk deletion job
  • Delete suspended workflows
  • Delete Email attachments if they are no longer required
  • Delete Notes with attachments if they are no longer required
  • Delete bulk duplicate detection jobs and associated copies of duplicate records
    • Every time that a duplicate detection job runs, a copy of each duplicate record is stored in the database.
    • Delete by navigating to Settings -> Data Management -> Duplicate detection jobs
  • Delete bulk import instances
    • Every time you perform a bulk import, there is a system job associated with that import.
  • Delete bulk Delete instances
  • Delete Audit Logs
    • Be cautious before deleting, as can no longer view the audit history for the period covered by that audit log.
    • Delete by navigating to Settings -> Auditing -> Audit Log Management -> Delete Logs

Refer below articles for more info.

Manage Storage

Free storage space


Categories: CRM, Dynamics 365 Tags: ,

D365 – Multi Select Option set JScript Syntax

November 21, 2017 4 comments

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

// Non-IE Browser
var isCitySelected = Xrm.Page.getAttribute(“new_branches”).getValue().includes(100000000);

// IE Browser

var isCitySelected = Xrm.Page.getAttribute(“new_branches”).getValue().indexOf(100000000)>=0;

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.