Tip #633: What’s to love about the Dynamics Data Loader

Although it has been derided by some as a glorified import utility, Scott “Silverlight Terminator” Durow sees tremendous value in the Azure based Dynamics Data Loader for CRM Online (currently in preview).

Scott says:

I love the fact that you can stage the data without the 32MB file limit and then edit in Excel to correct problems. I also love that you can specify older createdon dates

Tip #631: Azure ML is coming to Dynamics CRM

One of the most exciting upcoming features in CRM Online is Azure Machine Learning integration (under In Preview):

This release will introduce scenario-based Machine Learning (ML) integration with Azure ML for product cross-sell recommendations, and auto-suggest of relevant knowledge articles and case topic analysis. These scenarios are based on integration with Azure ML APIs for recommendations and text analytics. Azure ML integration offers a configuration experience and insights integrated into the CRM user interface. No data scientists required!

Can’t wait!

Azure Machine Learning

Tip #630: No flow – no documents

SetWordTemplate parametersWe did show how to generate documents in code, however, generating documents in a workflow using SetWordTemplate action proved to be just as elusive.

The problem is that the entity itself does not appear in the list of parameters for the action, making it impossible to generate the document.

As strange as it sounds but:

Entity needs to be enabled for the Business process flows to appear in the list of parameters for the SetWordTemplate action.

Thanks to Matt for raising the issue.

Tip #629: If your CRM report comes back empty

We observed this behavior on CRM 2013 SP1 and and CRM 2015 Update 0.2 on-premises. The report runs fine for small ranges (e.g. dates) but, as the range (and number of records to be processed) increases, report comes back blank, as if it didn’t run at all. No errors in CRM, SQL Server or SSRS logs. Both versions, SSRS and fetchxml, choked.

While we were unable to get to the bottom of this behavior, everything points out to the SSRS simply running out of some resources and quietly discarding the report.

To avoid excessive resources consumption:

  • If your report uses aggregates, move whatever aggregates you can to SQL Server. SQL Server will do the job of calculating your SUMs and AVGs better and much faster.
  • Avoid references and formulas involving report cells. Instead of ReportItems!foobar.Value use Fields!foobar.Value where possible. To get correct values from the cells, SSRS needs multiple passes over your report, slowing things down and consuming resources.
  • The above especially true when any grouping is involved. In other words, avoid aggregates over ReportItems like a plague.

Our results of following our own advice:

  • Original report for 3 months – 8 seconds, 12 months – blank.
  • Enhanced report for 3 months – .5 seconds, 12 months – 2 seconds.

Tip #628: Get jQuery the hacker’s way

The official word is:

We do not recommend using jQuery in form scripts and ribbon commands.

Right. And what are we to do with thousands lines of code already relying on that miracle? People insert libraries and keep their fingers crossed or follow the wise ones and encapsulate the instance with jQuery.noConflict() call.

There is an easier way, though. Since CRM uses jQuery itself, you can try doing something as simple as:

if (typeof ($) == 'undefined') {
  if(!!parent) {
    $ = parent.$;
    jQuery = parent.jQuery;
  }
}

Brutal but Works on My CRM™

Note: MSDN warns that “Following Microsoft Dynamics CRM Online 2015 Update 1 … there may not be an instance of jQuery available” but I’m yet to see any evidence of that.

The usual warning: contains small parts, use at your own risk and do not operate boats or heavy machinery.

Tip #627: Smart duplicate detection

Woot-woot! Our video channel now has the official URL: https://www.youtube.com/CRMTipOfTheDay! (Hint: take a minute and subscribe). To celebrate this achievement, our video dude, Derik, has gone MIA. After 38 straight weeks of videos, can’t hold it against him.

So today’s tip is not a video but something that has been on my todo list for quite some time. In fact, the original code spans back to CRM 2011.

DVD RewinderDuplicate detection has always been a pet hate of mine – it’s a cool feature but the interactive dialog has usefulness level of a DVD Rewinder.

But the most annoying part is not even the dialog, it’s the fact that it pops up after all data entry is done, party is over and everyone’s gone home. Imagine frustration of the users who duly enter all contact data including marital status, fax number, blood type and assistance name, only to find out that the contact already exists.

There is a smarter way to do duplicate detection – by making it proactive and real-time. Enter RetrieveDuplicate message – we can send it to the server when attributes change to see if the record is a potential duplicate as user enters the data. How do we know what attributes to monitor? duplicaterule and duplicaterulecondition entities to the rescue, they define the attributes taking part in the active duplicate detection rules.

The solution steps (for CRM2015+):

  1. Download and install the unmanaged solution. Because it’s unmanaged, to remove it, you’d need to nuke by hand the resources it installs (there are only 4 of them)
  2. Create a copy of a contact form – no need to experiment on the good ones.
  3. At the very top, add a section and insert web resource alex_DDNotification.html. Name the control DDNotification.
  4. Add alex_xrmsvctoolkit.0.2.js and alex_duplicatedetection.js scripts to the form.
  5. Add call to AlexDuplicates.OnLoad to the form onload event.
  6. Make sure some duplicate detection rules are activated.
  7. As the form is loaded, code will retrieve duplicate rules from the server and attach onchange handlers to the form fields that are part of the rules.
  8. When any of these fields change, code will send RetrieveDuplicateRequest to the server to get the potential list of duplicates.
  9. If duplicates are found, warning section will be displayed listing the potential duplicates in the web resource area. User can continue as normal but now they are fully aware that record is a potential duplicate.

Smart Duplicate Detection in Action

Since users are now notified well in advance, you can go to Settings > Data Management > Duplicate Detection Settings and switch off duplicate detection on create and update.

This solution has been ported from CRM 2011 so before you pull out pitchforks and apply spießrutenlaufen:

  • It still uses XrmSvcToolkit. Yep, works fine.
  • It still sends custom-grown soap and fetch to the server.
  • It was not aware back then that jQuery on form script is a no-no (separate topic!)
  • Should be rewritten to use web api or at least SDK.Soap.js
  • Should be wrapped up as a single html web resource that combines both code and visualization.
  • Should deploy some timers to cater for fast operators
  • Contains small parts, not suitable for children, does not drive or operates heavy machinery.

BUT you get the idea!

Special thanks go to Oleksandr Klymenko for the initial implementation, and some good ideas and suggestions.

Tip #626: Teach your users to type-ahead

tl;dr

Teach your users how to use keyboard in a lookup control

Longer

I know it’s an old piece of wisdom but this morning I just couldn’t help myself when observing the typical frustrating pattern of a user trying struggling to fill in the lookup field: remove hands from keyboard, grab the mouse, struggle to position the mouse pointer over the magnifying glass button, click, look at the partial list, struggle to position mouse pointer over the scrollbar, scroll, click Look Up More Records, move hands to keyboard, start typing the name to search for, back to mouse, click magnifying glass, ad infinitum… You get the picture.

Do your users a favor and explain some fundamental keyboard operations in a lookup control:

  • Typing a search term in a lookup field and pressing TAB performs the quick search. You can use any of the search fields (e.g. phone number) as well as the * wildcard.
  • If a unique match is found, your job here is done!
    Type ahead in lookup control
  • If more than one record is found, CRM will display an exclamation mark and move to the next field. Just press Shift-TAB (you did know it goes back to the previous field, didn’t you?) and CRM will drop the list of matches. Use up/down arrows to navigate, press SPACEBAR to select.
  • Still not seeing the record? Press and hold down arrow until it hits Look Up More Records, press SPACEBAR. Here is your search dialog in all its glory.
  • If there is a value in the lookup field – press DEL button to clear it or just start typing if you’d like to replace the link.

Tip #625: The death of Activity Feeds has been exaggerated

Dynamics CRM TipperI’ll start today’s truckstop with a rant (which, in itself, is nothing unusual).
<rant>

</rant>

Jukka

New 2016 instances of CRM Online no longer show the custom entities under Settings – Activity Feeds Configuration. In an upgraded org these Post Configuration records are still available, however. Has the feature been deprecated?

The CRM 2016 documentation for Configure Activity Feeds states that custom entities are supported.

For activity feeds, you can enable customizable business entities and custom entities that are user-owned, team-owned or organization-owned. For a list of entities that you can enable for activity feeds, see Microsoft Dynamics CRM web application. On the nav bar, choose Microsoft Dynamics CRM > Settings. click Post Configurations. The Post Configurations area contains a list of entities that are configurable for activity feeds.

It’s not an environment specific issue. I first noticed this when a person posted a questions onto my blog, then I checked a recent customer org that’s been on 2016 from the start. It only has 30 default entities available for Activity Feeds, none of the 30 custom entities I’ve created there show up in the list.

Joel

Here’s what you need to do—on that view there is a refresh list button—not the one at the top but the other one on the list. Click that and then the custom entities will appear.

Tipp Jarr’s 1,000 words

Refresh Activity Feeds

Tip #624: Updating won opportunity fields

When I receive an email from Mitch “Only in Texas” Milam with the subject “Well, this is interesting”, I know it will be just that. Last week was no exception:

Did you know (in 2015 at least) you can change the processed and staged fields on a Won Opportunity, without reopening it?

No, I didn’t know but a quick check later, yes, indeed, it is possible to update the fields on a closed opportunity:

// let's close an opportunity
var oppClose = new Entity("opportunityclose");
oppClose["opportunityid"] = opp.ToEntityReference();
oppClose["actualend"] = DateTime.Now;
oppClose["actualrevenue"] = new Money(42.00m);

var response = svc.Execute<WinOpportunityResponse>
    (new WinOpportunityRequest()
    {
        OpportunityClose = oppClose,
        Status = new OptionSetValue(3)
    });

// and then bump budget and estimates
var e = opp.GetAttributeValue<Money>("estimatedvalue");
var b = opp.GetAttributeValue<Money>("budgetamount");
var updOpp = new Entity("opportunity")
{
    Id = opp.Id
};
updOpp["estimatedvalue"] = new Money(e.Value + 1m);
updOpp["budgetamount"] = new Money(b.Value + 1m);
svc.Update(updOpp);

Here you have it. My guess is that this change in behavior is to support modifications of the fields inside the business process flows which may continue “running” regardless of the opportunity state and locking down the fields would break the processes.