Restrict contact deletion on account delete

As per the OOB functionality all the child records of account like contacts, opportunities and activities etc., will be deleted on delete of account. But, in one of my project we got a requirement to remove the link with contacts instead of delete. I tried to customize the relationship but the CRM is not allowing us to do this.

2018-11-05_1514

Finally we ended up with writing the plugin to achieve this. We have to write this plugin on “Pre Validation” stage of “Delete” step on Account entity. The child records were not available in any other steps (Pre Operation for ex) as the CRM platform deletes all the child records first and then account. The following is the plugin code.


IPluginExecutionContext pluginContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService organizationService = serviceFactory.CreateOrganizationService(pluginContext.UserId);
EntityReference targetEntity = (EntityReference)pluginContext.InputParameters["Target"];

QueryExpression getContacts = new QueryExpression("contact");
getContacts.Criteria.AddCondition(new ConditionExpression("parentcustomerid", ConditionOperator.Equal, targetEntity.Id));
EntityCollection allContacts = organizationService.RetrieveMultiple(getContacts);
foreach(Entity contact in allContacts.Entities)
{
Entity contactToBeUpdated = new Entity("contact");
contactToBeUpdated.Id = contact.Id;
contactToBeUpdated.Attributes["parentcustomerid"] = null;
organizationService.Update(contactToBeUpdated);
}

Happy coding !!!

Use visual controls + calculated fields to create an in-form dashboard

Want to add some sizzle to you form configuration? Phil Dudovicz recommends using visual controls with calculated fields to create a nice looking dashboard in your Dynamics 365 Unified Interface form. The following is an example of an investor form that visually displays relevant investor data.

Let’s take a closer look at how this is built:

  1. Current Year return

  • Calculated Field
  • Data Type: Decimal Number
  • Field Type: Calculated
  • ((new_investmentvalue – new_investmentvaluejan1) / new_investmentvalue) * 100
  • Control: Arc Knob
  • Value: hsl_currentyearreturn
  • Min: .1
  • Max: 15
  • Step: .1

2. Return vs. Goal

  • Data Type: Decimal Number
  • Field Type: Calculated
  • (new_investmentvalue / new_investmentgoal) * 100
  • Control: Arc Knob
  • Value: hsl_goalprogress
  • Min: 0
  • Max: 100
  • Step: 1

By combining visual controls with calculated fields you can easily add visual context to a record and give your users a richer user experience.

Or condition between linked entities or multiple entites in MSCRM Fetchxml

We got a requirement to create view on Accounts which I own or which I am following. In this scenario we may not able to apply “OR” condition for the filters as the filters are split between the two entities (Account and Follows). We can achieve this using the below fetchxml but we can’t build this through Advanced Find. So either we can create a View through code or provide a report with the below fetchxml.

2018-10-25_1107

 

Hope it helps.

Set Default View to Inline Lookup View

Recently we got a requirement to set default view for marketing list inline lookup view on Contact Form. As we can’t customize the inline lookup view directly on Form editor, we need to write a piece of JS code to achieve this. The tricky part is to get the control name of the inline lookup. You can access the control like “lookup_subgridname” (case sensitive), for ex, in my case: “lookup_Marketinglisten”. We need to use “setTimeout” as the control will take some time to load on the Form.

JS Code (Form OnLoad event)

function filterMarketingListInlineLookupView() {
var marketingListInlineLookup = Xrm.Page.getControl(“lookup_Marketinglisten“);
if (marketingListInlineLookup) {
var activeMarketingListViewId = “{4bee031e-04d6-e811-8160-5065f38a4a31}”;
var defaultView = marketingListInlineLookup.getDefaultView();
if (defaultView != activeMarketingListViewId) {
marketingListInlineLookup.setDefaultView(activeMarketingListViewId);
}
}
setTimeout(function () { filterMarketingListInlineLookupView(); }, 500);
}

Hope it helps.

Microsoft eBook Giveaway

Microsoft eBook Giveaway: Millions of Microsoft e-books available for free download
This is the time of year again when Microsoft is giving away millions of e-books for free, this includes books for Windows servers, SQL Server, SCCM, exchange, PowerShell, Azure Cloud and etc.

Please make use of this opportunity and download any required e-book.

Checkout below MSDN blog for the list of available books/download links,

https://blogs.msdn.microsoft.com/mssmallbiz/2017/07/11/largest-free-microsoft-ebook-giveaway-im-giving-away-millions-of-free-microsoft-ebooks-again-including-windows-10-office-365-office-2016-power-bi-azure-windows-8-1-office-2013-sharepo/

 

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