CRUD Operations with javascript from V9.0

Microsoft introduced an awesome feature for developers with V9.0 called Xrm.WebApi. With this feature it is very easy to perform CRUD operations using javascript code. Earlier to v9.0, to perform CRUD operation in Dynamics CRM we need to create our own library or used other third party libraries or used XmlHttpRequest and ajax request. Example code to perform CRUD operations using Xrm.WebApi feature

  1. Create
This image has an empty alt attribute; its file name is image.png

2. Update

3. Delete

4. Retrieve

How to use special date operators (last-month for ex) in OData and MS Flow

Today we got a requirement to fetch all the records that are created in the last month by using MS Flow. We can do this by using “Dynamics 365 List records” action and we have to provide OData filter query for this action. I tried to use the same “last-month” operator that we use in the fetch xml. But this will not work for OData query. We need to use “LastMonth” function for this as defined in this link. The below are the examples to use these date functions.

In OData Query

?$filter=Microsoft.Dynamics.CRM.LastMonth(PropertyName=@p1)&@p1=’createdon’

In MS Flow

Hope it is useful….

Custom code in “Convert To Case” OOB ribbon button

Today we got a requirement to perform some logic on the create of case by using “Convert To Case” button on email activity. The logic shouldn’t execute if the case is created manually (Service –> Case –>  +New). I decided to write a plugin on create of case and perform my logic but the problem is to identify whether the case is created manually or using “Convert To Case” button. Case record is not holding any reference of source email to distinguish. After some research I decided to write a plugin on “Update” of “Email” entity (filtering attribute: regardingobjectid). Whenever an email is converted to case, the platform updating the regarding field with the case that is newly created. So I felt this way I can identify the case which is created by using “Convert To Case” button. However, my plugin executes whenever some one update the regarding field manually on email entity, so I used the following conditions in my plugin to avoid this scenario.

  • Depth should be more than 1
  • Regarding shouldn’t hold any value in PreImage and should hold the value in PostImage
  • “Subject” of email should be same as the “Title” of the case     

Code

              IOrganizationService organizationService = localContext.OrganizationService;
            ITracingService tracingService = localContext.TracingService;
            IPluginExecutionContext context = localContext.PluginExecutionContext;
            if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
            {
                Entity targetEntity = (Entity)context.InputParameters["Target"];
                var targetRegardingObject = targetEntity.Contains("regardingobjectid") ? targetEntity.GetAttributeValue<EntityReference>("regardingobjectid") : null;
                if (targetRegardingObject != null && targetRegardingObject.LogicalName == "incident")
                {
                    Entity preImage = (Entity)context.PreEntityImages["PreImage"];
                    Entity postImage = (Entity)context.PostEntityImages["PostImage"];
                    var preRegarding = preImage.Contains("regardingobjectid") ? preImage.GetAttributeValue<EntityReference>("regardingobjectid") : null;
                    var postRegarding = postImage.Contains("regardingobjectid") ? postImage.GetAttributeValue<EntityReference>("regardingobjectid") : null;
                    var postSubject = postImage.Contains("subject") ? postImage.GetAttributeValue<string>("subject") : string.Empty;
                    var incidentRecord = organizationService.Retrieve("incident", targetRegardingObject.Id, new ColumnSet("title"));
                    var caseTitle = incidentRecord != null && incidentRecord.Contains("title") ? incidentRecord.GetAttributeValue<string>("title") : string.Empty;

                    if (context.Depth > 1 && preRegarding == null && postRegarding != null && caseTitle == postSubject)
                    {
                        //Your code is here
                    }
                }
            }

The above code is perfectly working for the scenario that I explained above but I am happy to hear suggestions and any scenarios that I have not considered.  

Limitations of Business Rule with Mobile App

One of our customer reported that couple of Business Rules are not working in Mobile app which are working perfectly in Web application. Spent so much time to understand the problem with Mobile app and finally figured out that one tab on the contact form is not loaded in mobile app because of maximum 5 tabs allowed limitations. Some fields that we are referring in the  business rules are part of this missing tab. So, business rule trying to lock (unlock, mandatory, setvalue etc.,) the field which is not loaded on the form and failing. Finally we decided to create a new form by considering the limitations with mobile app and the business rules that we implemented.

Below are the limitations of Forms in mobile app

  • You shouldn’t have more than 75 fields on the Form
  • You shouldn’t have more than 5 tabs on the Form
  • You shouldn’t have more than 10 sub grids on the From

I think the above numbers we can adjust with some settings but these are defined by Microsoft for optimal performance. The components that are exceeding the above numbers will not be shown on mobile app.

Hope it helps !!!

Organization Insights in Dynamics 365

Dynamics 365 has included a feature to allow you to view some collected statistics on various operations within your Dynamics CRM organization. Organization Insights can be installed into Dynamics 365 systems from Microsoft Appsource. The installation is painless but can only be applied to cloud based organizations that have been upgraded to Dynamics 365. By default, the Organization Insight dashboards are only available to System Administrators and Customizers.

After enabling this feature, a new Dashboard called “Organization Insights” will activate. This dashboard contains the following information

 

Total Active Users Total number of active users (unique users) who performed an operation that caused one of these SDK calls: Retrieve, Retrieve Multiple, Delete, Create, and Update.
Total API Calls Total number of API calls that were made by the Dynamics 365 instance for the selected time period.
API Success Rate This chart shows the API success rate as percentage of total API calls that were made in the Dynamics 365 instance over the specified time.
Plug-in Executions This chart shows how many plug-ins have been executed in the Dynamics 365 instance over the specified time.
Total Operations This chart shows how many operations (create, update, deletes, reads) have occurred in the Dynamics 365 instance over the specified time.
Most Active Users (Changes) List of most active users who performed an operation that caused a CreateUpdate, or Delete SDK call in the Dynamics 365 instance over the selected time period.
Top Plug-ins ByFailures This chart shows top 10 most failing plug-in in the Dynamics 365 instance over the specified time.
Total Active Users Total number of active users (unique users) who performed an operation that caused one of these SDK calls: RetrieveRetrieve MultipleDeleteCreate, and Update.
Total API Calls Total number of API calls that were made by the Dynamics 365 instance for the selected time period.
Most Used Entities Ten Entities which had the most RetrieveRetrieve MultipleDeleteCreate, and Update SDK Calls.
Most Active Users (Reads) List of most active users who performed reads (Retrieve and RetrieveMultiple SDK calls) in the Dynamics 365 instance over the specified time.
Total Page Requests The number of page load requests for forms, dashboards, and reports. This is the count of requests received by the Dynamics 365 server. Pages that are cached while browsing won’t be counted.
Most Active Users (Changes) The top ten users who performed the most change operations (creates, updates, deletes) in your Dynamics 365 instance.
Total Operations This chart shows how many operations (create, update, deletes, reads) have occurred in the Dynamics 365 instance for the selected time period.
Active Users Performing Specific Operations Total number of active users (unique users) over time who performed an operation that caused one of these SDK calls: RetrieveRetrieve MultipleDeleteCreate, and Update.
Active Users Number of active users (unique users) in your instance who performed an operation that caused one of these SDK calls: RetrieveRetrieve MultipleDeleteCreate, and Update over time.
Most Active Users Performing Operations List of most active users (unique users) over time who performed an operation that caused one of these SDK calls: RetrieveRetrieve MultipleDeleteCreate, and Update.
Most Used Custom Entities List of custom entities which had the most RetrieveRetrieve MultipleDeleteCreate, and Update SDK Calls.
Most Used OOB Entities List of out-of-box entities which had the most RetrieveRetrieve MultipleDeleteCreate, and Update SDK Calls.
System Jobs Pass Rate This chart shows the system job’s pass rate as percentage of system jobs that were executed in the Dynamics 365 instance over the specified time.
System Jobs Throughput/Minute This chart shows the average system jobs that have been executed per hour in the Dynamics 365 instance over the specified time.
Executions and Backlog This chart shows the number of executions and the backlog for system jobs in the Dynamics 365 instance over the specified time.
Most Active Workflows This chart shows top 10 executed workflows in the Dynamics 365 instance over the specified time.
Top Workflows ByFailures This chart shows top 10 failing workflows in the Dynamics 365 instance over the specified time. Click on a workflow to see the failures and their number of occurrences.
Plug-in Success Rate This chart shows the plug-in pass rate as percentage of total plug-in executions that were executed in the Dynamics 365 instance over the specified time.
Plug-in Executions This chart shows how many plug-ins have been executed in the Dynamics 365 instance over the specified time.
Average Plug-in Execution Time This chart shows average time taken to successfully execute a plug-in in the Dynamics 365 instance over the specified time.
Most Active plug-ins This chart shows top 10 executed plug-ins in the Dynamics 365 instance over the specified time.
Top Plug-ins ByFailures This chart shows top 10 failing plug-ins in the Dynamics 365 instance over the specified time.
Dynamics 365 Tenant Storage Utilization This chart shows the storage used by all the Dynamics 365 instances of your tenant out of the total storage allocated to the tenant.
Storage By Dynamics 365 Instances (MB) This chart shows the breakdown of the storage used by the Dynamics 365 instances of your tenant.
Top Tables By Size – Current Dynamics 365 Instance This chart shows top 10 largest tables by size and their row count in the Dynamics 365 instance database.
Common Tables BySize – Current Dynamics 365 Instance This chart shows the size and number of rows of some common tasks of tables in the Dynamics 365 instance database.
API Success Rate This chart shows the API success rate as percentage of total API calls that were made in the Dynamics 365 instance over the specified time.
Total API Calls This chart shows how many API calls have been made in total in the Dynamics 365 instance over the specified time.
Most Used API This chart shows top 10 most executed API calls in the Dynamics 365 instance database.
API Calls This chart shows how many API calls have been made over time in the Dynamics 365 instance over the specified time.

The available charts are customizable so that you can build custom Dashboard to meet your needs, but an additional feature will allow developers to extend the out of box charts to create their own charts.

Organization Insights will be helpful to system administrators looking for data about who is using CRM most effectively as well as which users might need some additional training to have the best experience.

Some of the screen shots of this feature