Basic List Prep in Excel – Splitting A Full Name into components

While it’s easier to import data to Dynamics CRM using the data templates, prepping that data can take a little work.  One of the most common things to deal with is splitting a “Full Name” from a source file, which needs to be imported to CRM as “First Name”, “Middle Name”, “Last Name”.

Let’s assume the source file uses the format of “[Last Name], [First Name] [Middle Initial]”.  This makes it just a little too complex to use the Text-to-Columns feature in Excel (but note, if you’re dealing with a basic “Last, First” format, keep it simple and use Text-to Columns).

Rice, James P

Easy enough to do by hand…but what a hassle if you’re doing a thousand records or more.

Our solution?  Build 3 simple formulas to handle that manual work.

Excel Formulas

Looks like gibberish, right? Read on for an explanation

Like Billy Blaze, I find it’s easiest if we break things down.

Start with the Last Name (Column C)

We know that the last name starts at the left of the cell:

=LEFT(A2,FIND(“,”,A2)-1)

English:  Grab some characters from the left-hand side of A2.  How many?  One character behind the comma, so go find the comma in A2, then go back one character.

Pluck out the First Name (Column D)

This part is a little trickier, but not too much.  We can’t use the left() function any more since it’s in the middle.

=MID(A2,LEN(C2)+3,LEN(A2)-LEN(C2)-4)

English: Grab some characters from the middle of A2, starting 3 characters after the last name.  How many should we grab? The total length of the Full Name, minus the length of the Last Name, minus four characters (2 spaces, 1 comma, and 1 Middle Initial)

Grab the Middle Initial (Column E)

This one’s the easiest to decipher…

=RIGHT(A2,1)

English: Grab some characters from the right-hand side of A2.  Just 1 this time.

With those three formulas, here’s what we end up with:

End Result

Looks much prettier now.

The rabbit hole goes deeper

When you’re sent a file to work with, it’s pretty rare that names fall into a perfect little “Last, First MI” format.  There’s a few ways to deal with this.  I’ve put together a workbook with this and a few other examples of splitting up full name data, which you can feel free to thieve from me.

  • First MI Last
  • Last, First [optional MI]
  • First [optional MI] Last

These cover a few different methods for carving up the data, but are by no means exhaustive.

Note, it’s important to know your data that you’re starting with.  Take some time to ask some questions:  Are all of the names in the same format?  How should a record be handled if the name is missing?  Is there funky CaPITAlizAtion that needs to be dealt with?  Does anyone have two middle initials, or maybe a space in the middle of their name?  Picking through these issues is often the most time-consuming part of prepping a list of data.

I’m always tempted to try to write some “super formula” that is so smart it can handle any case you run across…but remember, if there are only twenty records where there are two middle initials or a space in their first name, it’s often quicker to do those twenty by hand and use a simpler formula to help out with the rest.  You’ve been warned 🙂

Once you’ve split the name into component parts, you can copy/paste these columns into a CRM data template and import the results!

Entering lists of Option Set values into MS CRM

A co-worker recently shared this project with me as we’ve had some experience with clients who had large number of options that needed to be added to Picklists.

List showing state abbreviations

Fifty US States, maybe some Canadian Provinces

Unfortunately, Dynamics CRM doesn’t offer a way to batch import these lists, rather it’s up to the administrator to add them one-by-one.  Adding in a dozen of these isn’t so bad…especially since you should only have to do it once…but when you start looking at two dozen, fifty, or more of these it becomes a real hassle (and a hotbed for fat-fingered garbage data).  That’s where the CRM Option Set Utility comes into play.

The goals of the project are simple enough:

  1. Provide a resource for the download and maintenance of the CRM 2011 Option Set Import tool which is available for download.
  2. Community resource library of contributed Options Sets that can be used by any Dynamics CRM Organization free of charge.
Application Screenshot

You mean all I need is an Excel spreadsheet with the values in it? Count me in!

After spending some time with the application, specifically testing it using on-premise CRM Organizations, there are a few things that I’ve found worth highlighting:

  • It not only imports the option set, it creates the field from scratch (so you can go straight from an Excel list without having to first create a placeholder in CRM). 
    • Once connected to a CRM Organization, it the UI presents a list of entities you want the Option Set created on.
    • You choose the entities, and whether the option set should be Local to each entity or Global.
    • Note, I had some issues during my testing when I tried to specify a global option set and selected entities at the same time.
      • My workaround for global option sets was to import the option set via the tool, then manually create the attribute on each entity linking it to the global option set.
      • I plan to seek assistance in the forum, but have not been able to get a forum account as of yet.
  • There is good flexibility with respect to setting both the “Label” and “Value” for each item
    • 3 options exist.
      • 1) Start with 1, 2, 3…..
      • 2) Use the defined numbering prefix from a selected Solution in the CRM Organization.
      • 3) Define in Column B of the source spreadsheet.
  • The tool is meant to Create these option sets, not to Update existing option sets.

The bit I like is the community aspect of hosting a repository of common option sets.  There’s about a dozen so far, but as this builds out it will hopefully be a first-stop when looking for a cleansed list like this.

2

CRM Report – Removing HTML tags from an Email Activity Detail

I’ve been working with Dynamics CRM reports quite a bit over the last few months.  Most of the work has been using the BI Dev Studio (BIDS) in Visual Studio.  It definitely falls into the artful science category for me, with flavors of Excel, SQL Server, and even Publisher when developing a report.

In the case of displaying Email activities, specifically the body of an HTML email, the art takes a decidedly sad turn.

Simple HTML-formatted Email

Yes, this seems like a nice basic email. Nothing fancy going on here…

Okay, let’s see what that looks like in a simple report that shows a summary of email messages….

HTML tags show up in report

Gah, what happened!? It seemed so harmless…Text and a little image.

This is useful for…nearly nobody.

Matrix Code

Mr. Anderson, maybe you understand this…

There are many ways to try to tackle this…ranging from CRM plug-ins, to complex report design, to, well, something a mentor of mine tipped me off to.

Microsoft.Crm.Reporting.RdlHelper.HtmlUtility.RemoveHtml(field)

This gets used in the report design as an expression, replacing the normal field reference in the report design.  It uses a basic utility that strips out the HTML leaving only the plain text behind.  Okay, if that sounded clunky, a picture is worth a thousand words:

HTML vs Plain Text

Ahh, now that’s much better.

There are certainly more elegant ways of doing this, but if the key is to provide easy, readable email contents in a report this sure foots the bill!  From a user perspective, to see the full HTML version, I like to add in a clickable link to the email that pops the CRM Email Activity record.

I picked up a little tidbit while working through some applications of this:  If you try passing a null field using this utility  it returns an ugly little #Error instead of a blank string.  Also, SSRS will still throw the #Error even if you’ve included an IIF statement in the expression to make sure there’s a value before calling the utility.  Below is a little workaround that gets the job done.

Microsoft.Crm.Reporting.RdlHelper.HtmlUtility.RemoveHtml(field & “”)

If anyone knows an easier way to do that, please drop the details in the comments section.

Again, there’s surely a prettier way to handle this, rendering HTML in the report or including some basic formatting, but this is pretty lightweight and works well when printing a basic list of emails with the body text in a report.

As far as I can tell, this utility is an undocumented feature of CRM, so quite technically speaking it is not supported by Microsoft and is something that they could yank out in a future release without notice.  That said, this is the method used in the out-of-the-box CRM reports to strip out HTML tags.

Objective: Strip out HTML tags from an email message when displaying in a CRM report
CRM Version: Undocumented feature. I’ve tested with CRM 2011 through UR8
Valid as of: 9/10/2012
Permissions Required: Create/Write reports.

UPDATE 9/11/2012:

I received a question regarding a problem someone was having when importing a report that leveraged the expression above.  After a little troubleshooting, the answer was that the report lacked a reference to the following Microsoft assembly:

Microsoft.Crm.Reporting.RdlHelper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Vanilla CRM reports and those reports created using the built-in CRM Report Wizard include this reference automatically.  However if you build your own report from scratch, you’ll need to add this manually.  With the report file open in Visual Studio BI Dev Studio, hit the menu item at Report->Report Properties…  Next, click Add and paste in the reference to the assembly and click OK.

Report Properties Window

Way to go, Bobby!

Thanks for the question!  Other comments and questions are welcome.

1

Importing a list of records into MS CRM

In the last post, we downloaded a Dynamics CRM Import Template.  Now, it’s time to get some data INTO the system…since that’ll be much more useful.

Contacts are a pretty common import, being something that most sales users will want to do early on.  Fortunately, it’s a super simple process to do this!

Objective: Download the import templates specific to your organization from the CRM application.
CRM Version: CRM 2011, any version
Valid as of: 8/27/2012
Permissions Required: Read/Write Import Job and at least User level Create permissions for the Contact entity.

Steps:

  1. In the navigation pane, click File->Tools->Import Job
  2. Browse to the .xml/.csv/.zip file that has been prepared
  3. Click Next
    Select A File
  4. In this example, since we’ve used the templates that came from CRM, there’s no need to modify the data map (We’ll cover data maps in another post), so click Next
    Select Data Map
  5. Accept the default duplicate setting (do not allow) and choose yourself  as the record owner.
  6. Note, the Owner field can be set in the import file, so this is really a means to set the fallback owner if there’s not an exact match
  7. You’re ready to Submit the Import Job
  8. The import will be queued up, and the CRM Async Service will do the rest
2

Download Data Templates for Importing Data into MS CRM

Whether I’m just starting a CRM project, or there’s a list of [something] that someone needs imported into Dynamics CRM.  One of the easiest ways to get a list of records imported is using a file import…and the biggest hassle of that is making sure the field mappings are set up.

The vanilla product has an easy way of handling this, providing a way to download a template, specific to the record type you want, which includes all of your customized fields as well.  It’s pretty slick not having to set up this field mapping on your own, and if you have some Excel data that you can copy/paste into the appropriate columns, you’re in business.

Objective: Download the import templates specific to your organization from the CRM application.
CRM Version: CRM 2011, all versions
Valid as of: 8/20/2012
Permissions Required: All default security roles.

Steps:

    1. In the navigation pane, click Settings.
    2. In the System section, click Data Management
    3. In the main window, click Templates for Data Import
    4. A window will pop up.  In the dropdown, select the type of record you will be importing.
    5. Once selected, click the Download button.
    6. Save the file to the desired location.
    7. Repeat steps 4 , 5, and 6 for each record type template.
    8. Click Close when complete.
1 6 7 8
>