Multilanguage Dependent Option Sets for Dynamics CRM

When I needed to create some dependent option sets for a client in Dynamics CRM, I knew where to start: GOOGLE. One of the top results for solving this issue, was this MSDN sample: https://msdn.microsoft.com/en-us/library/gg594433.aspx

The provided sample solutions worked like a charm. Time to implement it in my real world scenario. The documentation on the MSDN sample page clearly states that the label values in the xml are solely there for readability purposes. They are NOT used in the script.

Image1

Well, I don’t like typing too much, so when creating my own xml, I left out each and any label attributes.

Imagine my surprise when I used this on my form and the result of the dependent option sets looked like this:

Image2

At first I thought I made a mistake and started going through my xml. Except for having no label attributes whatsoever, the file was ok. That’s when the developer in me started going through the actual code. And surely, while the sample documentation states that the label values are not used. They are …

Luckily, there’s just a little bit of extra code needed to make this work as promised.

These steps are necessary to make this work:

  1. During the initialize stage, get a hold of the original option set values of the dependent option sets. They will be in the correct language, provided that translations are in place in your environment.
  2. When creating the options array for each parent item, get the label from the original option set value that we retrieved in step 1.
  3. In the interest of readability, write a separate function to do the search necessary in step 2.

The code before the change:

Image3

The code after the change:

Image4

I left the option to set a label value provided in the xml, just in case the translated text is not found. Which for me would result in null labels again, but hey, I will configure this correctly so it won’t be needed, right?

The result after changing the script:

Image5

A downloadable version of the full improved javascript file can be found here .

This concludes this blog post, hope it helps!

 

Ruben Biesemans

Ruben Biesemans

Analyst Developer @ Spikes

Advertisements

One response to “Multilanguage Dependent Option Sets for Dynamics CRM

  1. I uploaded a slightly better implementation for the fully downloadable file where each ‘optionToShow’ is an actual Xrm.OptionSetItem instead of just an object. This removes the need to do “toString()” for comparisons on the value.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s