Tip #423: Tipsters guide to folder-level tracking: administration

Welcome to video Fridays. You’ve heard it. We now even have our own video dude as part of the team: Derik “Foobar” Bormann . We aim to give you something useful in time it takes to consume a cup of coffee or other beverage of your choice. In the break, between your spurs of awesomeness creating another CRM gem.

Give us your feedback, all of it: good, bad, and ugly, I’m sure we can take it. Suggest new topics either in comments or by sending your ideas to jar@crmtipoftheday.com.

YouTube player

 

Tip #422: Search faster by searching less

I’d like to be able to search contacts by first name and last name. And middle name. And birthday. And employee id. While you’re at it, add spouse name, comments, city, country, phone number (all of them) and freight terms.

So, what a smart CRM consultant to do? Open Quick Find Active Contacts view and use Add Find Columns button to add a smorgasbord of the columns:

Ultimate search

That’s Spießrutenlaufen right there.

What a smarter CRM consultant to do? Explain to the customer that adding a single column introduces a performance penalty that will be amplified as the database grow.

For example, in one of the recent cases we had a CRM database with approximately 500K contacts, simple search was taking close to 30 seconds. After discussing the issue with the business, we reduced number of fields from 15 to 4 (first and last names, email, internal id). Even a wildcard search takes less 2 seconds now.

Whether you’re building a salad or a CRM system, restraint yourself, people, when it comes to the ingredient count.

Tip #421: No email without activity

Ability to enable entities for emails is great – it’s another useful slice of functionality previously reserved only for contacts and accounts. If you are like me and prefer a minimalistic approach to entity design, you may be tempted to check the box enabling emails and be done with it. This is not going to work well, unfortunately, without enabling activities as well:

Email without activity

It’s one of those things that make total sense when you think about them: emails that you are about to send are activities, right?

Thanks to my good comrade Oleksandr “Salo” Klymenko for the tip!

Tip #420: If your child workflow needs more than one entity

CRM workflows always require an entity to run. But what if you’d like to create a child workflow but need more than one entity or additional parameters? For example, while identifying the business opportunities for a professional photographer, you may want to invoke a workflow called Book the ceremony that involves two people. Let’s assume that someone else on your team will be creating the workflow taking care of the details such as whether it’s a civil or religious ceremony, genders of parties involved, dates, etc.

Option 1

Call custom actionIf your deployment is on CRM Online 2015 Update 1, child process can be created as a global, i.e. not requiring a specific entity instance, custom action.

Note:Do not declare your parameters as Entity – that will make the action not available in workflow UI.

Option 2

Call child workflowIf you don’t have access to all the wonderful new features in CRM Online then you can use what I call a “piggy-in-the-middle” approach: design a helper entity that would hold all the information required, create an instance, fill all the fields and pass that instance into a child workflow.

Note:Since there is no delete operation in CRM workflows, and if workflow volume calls for it, you’d probably want to execute a cleanup bulk delete job removing piggy instances for the completed workflows.

I think I owe myself a treat
Gaytime Multipack

Tip #419: How to sign out from ADFS in one click

Single CRM installation is capable of hosting multiple organizations. As administrator, you probably have some test accounts handy to login as normal users. Many + many sometimes does not end up well:

Incorrect login

This is what you see when you do have an Active Directory login but it’s not mapped into this organization. “That’s cool”, I hear, “I’ll just sign out and come back as another mighty user”. Ahm, do you see a sign out button? You can try restarting the browser, deleting cookies, etc. Some things work in some browsers, some – in others. There is an easier way, just enter a sign out URL:

<your ADFS login server>/adfs/ls/?wa=wsignout1.0

And you’ll see the soothing

You have signed out.
For improved security, we recommend that you close all browser windows at the end of your online session.

So the next time you sign out from CRM, make sure to bookmark the URL. Even if you do remember all the logins, this shortcut will be just one click away and not two when you use sign out link in CRM.

Tip #418: 3 ways to find the blocking attribute

Dynamics CRM TipperShan “Smoke ’em” McArthur wonders during another mini truck stop if there is any way to find a blocking attribute using nothing but its id.

The error message usually looks like this:

A managed solution cannot overwrite the Attribute component with Id=e7840116-dead-beef-a5e5-8b5cb27e9509 for the CRM org noneofyourbusiness.crm.dynamics.com

That said, I have no way of looking up this field. That Guid is not referenced in the managed solution file that I am trying to import that is throwing that error, and the field ID is not displayed in any UI in CRM. With on-premise, I have to break out SQL tools, but at least I can look it up. It is different with every deployment so I can’t just look it up in a reference CRM implementation either.

Good

Joel couldn’t resist dropping in his $0.02:

If you go to customization and open a field customization, you can find it by replacing the attribute id in the URL.

You might have to try different entity id’s, but I’ve been able to find one that way

<crmurl>/tools/systemcustomization/attributes/manageAttribute.aspx?
appSolutionId=%7bFD140AAF-BEEF-DEAD-BD17-0019B9312238%7d
&attributeId=%7bE388A767-F00D-BEEF-BF28-D3E7E7AD1EB8%7d
&entityId=%7ba359f963-DEED-4a32-b607-bada5522b678%7d

Better

Adam “Escalate This” Fish suggested the supported and a much shorter, I must say, path:

Would the Metadata Browser help?

https://msdn.microsoft.com/en-us/library/hh547411.aspx

Best

Not convinced, Jim “Mr SDK” Daly pointed out the futility of the exercise and directed us all to learn C#:

You should be able to use metadata query for this.

Metadata browser wouldn’t be helpful unless you already know the entity it belongs to.

With metadata query you need to return all entities and all attributes, but then include the filter criteria for the specific attribute metadataid.
Then loop through all the entities looking for the one where the attributes collection length is 1.

Disclaimer

No GUIDs were harmed or reused during this stop.

Bonus Double Dip

Episode 3 of the CRM Audio podcast is out now. We stage an exciting prize fight between CRM Online and On Premises, and Mitch Milam explains what’s the big deal with the new CRM Online web API. Listen here: http://crm.audio/episode-3-the-dynamics-crm-death-match/

Tip #417: Cancel waiting instances in style

We have posted multiple times about waiting workflows, and one of the big challenges surrounding them is that when you update a workflow definition, there is no way to cancel the waiting instances of the workflow in bulk. Also, jobs may go into waiting state if there is a condition that prevents the step from completing. For example, if you have a step to send email to a contact, and the contact doesn’t have an email address, the workflow will go into an indefinite wait status.

Gap Consulting from the UK has filled this gap with the latest update to their excellent Workflow Essentials solution. Their Workflow Executor tool in the solution now has the ability to select a workflow and in bulk cancel or retry all waiting instances of that workflow.

This will be helpful to clear out the waiting instances when you change a workflow definition, but also when you have a data condition that makes a bunch of workflows go into indefinite wait status, you can use the tool to retry the workflows after you have fixed the data issue.

Read more on the Gap Consulting blog.

Tip #416: You have OAuth token, now what?

You went through all the motions of authorization endpoints, return URIs, codes and whatsnot and finally got the magic mushroom authorization token. Now what?

Option 1

Use HttpClient to send requests to the CRM endpoints, add authorization token to the header of every request:

HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = 
   new AuthenticationHeaderValue("Bearer", accessToken);

Once reply is received, go through the pain of manually parsing the return values.

Option 2

Download CSDL file for OrganizationService, manually add a service reference to your project, generate custom organization context, then add some fairy dust:

var service = new CrmOrgContext(new Uri(ODataUrl));
service.SendingRequest2 += (sender, args) => 
   args.RequestMessage.SetHeader("Authorization", 
        "Bearer " + token);

// active accounts
var accounts = service.AccountSet.Where(
   a => a.StateCode.Value == 0);

Better but manual processing will still be required in some cases and we’ll have to refactor all our existing data access code.

Option 3

Spend 10 minutes reading What’s new for developers in CRM 2015, find new namespace Microsoft.Xrm.Sdk.WebServiceClient containing OrganizationWebProxyClient and change your code to:

var orgService = new OrganizationWebProxyClient(
   new Uri(serviceUrl), false)
   {
      HeaderToken = token,
      SdkClientVersion = "7.0"
   };
var userId = ((WhoAmIResponse)orgService.Execute(
   new WhoAmIRequest())).UserId;

These classes support executing message requests through the /web endpoint of the Discovery.svc or Organization.svc when authenticated with OAuth

Now old code works without any changes and authorization is transparent. Which is exactly what we’ve been trying to do all these years.

Tip #415: When deleting email enabled entities

If you remove a custom entity that is email enabled (allowing it to be selected as email recipient), you may run into the following issue after the entity is removed.

When going to an account and selecting the “Activity” tab of the activity/social pane, the following error appears

error

The trace log will reveal an error referencing the OTC of the entity that was deleted. The problem is that when the entity is removed, activities remain in the system that have activity parties associated with records from the now deleted entity. When the activity pane renders for an account, if there are any activities regarding that account that have activity parties from the deleted entity, the activity pane will throw an error. The solution is to delete all activity party records where the OTC of the partyid equals the OTC of the deleted entity.

Thanks to Scott Jung for this tip.

 

Tip #414: If Bing does not show up

Sometimes we all can suffer from a bit of scotoma — inability to see things right in front of your eyes. Today’s tip is from Matt Johnson is a timely reminder. Looks like some default settings in CRM may be subject to change without a notice (and without us noticing).

Bing settingsRecently we provisioned a CRM Online (2015 Update 1) site. After adding Bing maps onto the form they just wouldn’t show up. In fact, if you added them to the form in another section that was already there it made the whole section invisible.

After asking Microsoft what was wrong, they pointed out a (possible new) setting in Settings | Administration | General tab, which is called Enable Bing maps on forms. This was set to No by default. Maybe this tip will help someone else if they come across the same thing?