View Designer plugin in XrmToolBox

In one of my previous post I explained how to apply “OR” condition for the filters that are split between the two entities, however, these type of conditions were not possible to apply for views in MS CRM. But, now we have a new plugin called “ViewDesigner” introduced in our favorite XrmToolBox where you can apply whatever filter you want to the existing views in CRM.  Here is the link to know full advantages and usage of this plugin.

https://stoneridgesoftware.com/going-beyond-advanced-find-views-and-xrmtoolbox-view-designer-fetchxml-builder/

Hope it makes easier the developer effort !!!

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 !!!

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.