Multi-Select Option Sets: Part 2

Today I’m going to revisit one of my more popular posts: Multi-Select Option sets. This little JavaScript hack is a great way to present the selection of multiple option set values. The biggest problem with it is that it is absolutely not a supported customization, and with the latest release of CRM the previous implementation has started to break for many people.

Some of the great consultants here at Slalom, Ashwin Ravi and Deene Ogden, have converted the multi-select solution into a managed solution that implements this as a web resource, making it easier to deploy—and more important, 100% supported! That being said, here’s how to use the solution (found at the end of this post):
Place two fields on the form (an option set and a text field). Be sure to hide them after they’re on the form.Add the Multi-Select web resource to the form. In the parameters section, put the schema names of the fields you just created. The order matters, so put the option set first, then the text field. Note: Don’t include a space after the comma or you’ll get errors.

Go to the form properties and add the MultiSelect_OnSave.js library.

Finally, add an OnSave event referencing the Multi-Select library and pass the name of the web resource you inserted on to your form. If you need to add multiple Multi-Selects, then just create multiple OnSave events with each one referencing the different resources.

And that’s all there is to it! Here’s the solution. Happy CRM’ing! As always, this code is provided as-is and on warranty.

MultiSelectwOptionSet_1_0_3_managed

About Xavier Vargas
Slalom Consultant Xavier Vargas has worked with Enterprise CRM customers in numerous verticals. Based in Dallas, He has also delivered training engagements as an MCT (Microsoft Certified Trainer).

60 Responses to Multi-Select Option Sets: Part 2

  1. bladec59 says:

    Thanks for the update…but I guess I’m too much of a noobie. Just how do you go about ‘Modifying the Web Resource’? How do I get the web resource to my site to edit it??

  2. bladec59 says:

    Nevermind, I figured it out…still looking for a way to make this a ‘required field’ though. Suggestions??

    • If I were going to take a stab at doing this, I would create a new library with a single function that takes in a field as a parameter. I would then register the function in the onSave passing in the hidden Multi-Select Option Set Value field and the function would check to see if this field had a value. If no value is present, stop the save and alert the user. Hope this helps.

  3. Parvati says:

    Previously ,my script was working for crm2011 online, but now its not working,giving error ,There was an error with fields customized event,
    Field:window
    Event:onload
    error:undefined,what is the cause(may be UI upgraded),to make that script work again what i need to do ,plz let me know……

  4. Walker says:

    Does this disable the new sales process forms? I installed the solution, but cannot get the new UI with the sales process at the top.

    • Unfortunately, loading any scripts (OnLoad/OnSave/OnChange) will disable the new UI. We have compatibility with the new forms on the roadmap for a future release. Stay tuned.

  5. TEmer says:

    Do you know if this solution works on IE8?

  6. Pingback: Multi-Select Option Sets in Dynamics CRM « The Slalom Blog

  7. Leanne says:

    This works great but upon save I get an error that says

    —————————
    Message from webpage
    —————————
    There was an error with this field’s customized event.

    Field:crmForm

    Event:onsave

    Error:Object doesn’t support property or method ‘getObject’
    —————————
    OK
    —————————

    Any thoughts on what I am missing?

    • Dennis H says:

      I got the same error. When I changed webresource in the onsave parameters box to WebResource (case sensitive as it showed in my CRM) it worked perfectly after that. This was tested on UR12

  8. Sanjeev says:

    This is not working with UR 12 of CRM, with cross browser support.

    Thanks

  9. Dennis H says:

    There does seem to be an issue with using this solution when running Firefox on UR12. The formatting is off and some of the selections are “out of order” as compared to the same page in IE.

  10. Brenda Leon says:

    I followed all of the instructions and got this to work fine on a 30-day online trial (used for testing before I imported the solution onto client’s live online version. Worked fine testing, then when I got to my client’s environment, I get the below error – so I removed the web resources and unfortunately am still getting this error. Other odd results was, I got the multi select only when I created a new record. Opening an existing record, the web resource did not display (and got below error then as well). However, when previewing the Onload and simulating OnSave I get no problems.

    It seems to want to load the new forms with UR12, but I haven’t turned those on yet. The client can exit out and are able to continue on, but any ideas as to how this could have happened and what I can do to resolve it?

    btw: this error was copied when I tried to go into a contact record from the Outlook client. Wanted to see if I got the same results, which I do.

    Microsoft Dynamics CRM Error Report Contents

    1.0

    Unable to get property ‘clientHeight’ of undefined or null reference
    1
    /_static/_controls/ReadForm/ReadFormUtilities.js?ver=265373125
    /main.aspx?etc=2&extraqs=%3fetc%3d2%26id%3d%257b9A9A9005-4303-E211-B070-78E7D1623F9D%257d%26pagemode%3diframe%26preloadcache%3d1361844842482&pagetype=entityrecord
    anonymous(tabId,webResourcesInfo){if(!IsNull(webResourcesInfo))for(var$v_0=0;$v_0<webResourcesInfo.length;$v_0++){var$v_1=webResourcesInfo[$v_0].tabId;if((isNullOrEmptyString(tabId)||$v_1===tabId)&&Mscrm.ReadFormUtilities.isTabVisible($v_1)){var$v_2=$get(

    anonymous(tabId,webResourcesInfo){if(!IsNull(webResourcesInfo))for(var$v_0=0;$v_00)Mscrm.ReadFormControl.WebResourceImageControl.$2S($v_2);else$addHandler($v_2,”load”,Mscrm.ReadFormControl.WebResourceImageControl.$27)}}}

    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; InfoPath.3; Microsoft Outlook 15.0.4420; Microsoft Outlook 15.0.4420)
    en-US
    en-US
    en-US
    1440×900
    Outlook Laptop – Online
    2013-02-25T18:14:05

    1033
    1033
    1033
    1033
    {1BCBC5AB-9C12-4D8E-891C-ACE492DF613B}
    {55944824-C6F8-4F42-A9F1-4A58568B4C41}
    5.0.9690.3339

    • Brenda Leon says:

      I knew that once I posted something I’d find the answer. I had the Read Optimized selected in my options. Once I removed that, I’m back in gear. I’ll reimport the solution and try again. My apologies for wasting your time :).

      • Brenda Leon says:

        Once I reset the option, and reimported/setup the solution, it worked fine. One question – I take it you’re ordering the option list by data value and not the name, correct? Any way I can modify it without having to reinput the values by alpha order (would require a lot of updates especially if I we add more). Thanks.

  11. Dennis H says:

    Any word on anybody having issues in other browsers than IE after UR12?

  12. BillG says:

    IE and Chrome work fine, but Firefox as mentioned by Dennis works, but causes order and selection issues.

  13. Sanjeev says:

    I’m getting additional check box with empty label under Safari and Firefox.

    Does anyone is having same error?

  14. Dennis H says:

    Yes as I posted above, there is an issue in Firefox. The exact issue you are describing

  15. Sanjon says:

    Hi!

    It’s a great solution, but can you help me, how can i get selected values from javascript?
    Is there a simple way?

  16. jeff says:

    General Question….I work for a shipping company & was wondering if this code would work under the opportunities module for selecting multiple destination ports under the destination drop down box that I created? Within our industry this happens quite a bit – multiple destination ports for 1 opportunity. Our company used Sugar at one point in time & it was an automatic option.

  17. commenter12 says:

    That’s pretty cool, and it anticipates HTML 5, but instead of going to all that trouble, why not just create a bunch of Two Options fields? Those are supported out-of-the-box and can be turned on and off independently of each other.

  18. Voni Garrett says:

    Hello,

    I am trying to implement your code, and am missing something.

    When I display the form, the picklist displays as a regular picklist with no boxes and no ability to select multiple items. I am running IE 10.

    I believe I have followed the instructions, but am new to javascript. Any thoughts?

    Thank you!

    Voni

  19. cmadore says:

    Hi, the images on this post are broken.

  20. cmadore says:

    Hi,

    I was able to succesfully add this to a form once, but when I add a second one the option list does not show up. I did add multiple OnSave events referencing the different resources. Please advise. Thank you!

  21. GL says:

    Thank you very much!

  22. AndyL says:

    Am I assuming correctly that this still stores in a semi-colon delineated list in a single field? Can I use an advanced find to pull all records that contain a certain option in the list?

    For example, I’d like to “tag” opportunities with the multi select options for what products they may be interested in. Opportunity 1 is interested in products 1,3,5 and Opportunity 2 is interested in products 1,2,3. Can I then use this to pull up a report on all Opportunities interested in product 3?

  23. dennis says:

    This works great for us…thank you very much! One question though, I entered the items in my Option Set but they are not in Alpha order. I sorted them in the Field properties. I then went back to my form and noticed that they are not sorting by Alpha. What can I do to correct this? Thanks again!

    • Brenda Leon says:

      I had the same question – looks like they’re ordering the list by data value and not alpha, which doesn’t really work if you need to add new values. Awaiting a response 🙂

  24. Pedro Pablo says:

    The solution is very good for cross browser but en IE dont show the first item. can you helpme?

  25. Brenda Leon says:

    I am creating multiple MultiSelect Option sets on one form but am getting an error with the OnSave. Is there something I can do about that? Is this supported?

  26. Irina says:

    This solution works just perfect for us. Have just few quick questions:
    1.Is it possible to make “Select all” option to be able to automatically check all options.
    2.If I’m performing quick search it gives me the result based on first selection. For example if I have entire in State field”CA;AZ;NY” and in quick search I put “NY” it will give me no result, but if I’m searching by “CA” it can find my entry.
    Thank you!

  27. ABlair says:

    Thanks for the solution. What needs to change in order to have more than one multi-select option sets on a single form?

  28. Raj Patil says:

    I added the multi picklist to my Appointment form. When I open the Appointment form using WEB browser interface and create a new appointment and select some options from the picklist it works great. All the picklist items are saved. However, when opening the same form from OUTLOOK, I’m able to fill in the picklist details and save the forms without any error, but when I open the saved form I don’t see any of my picklist items saved. Any Idea why this could be happening ?

    Thanks !

  29. SPok says:

    Will this code work on CRM 2013?

  30. pearse says:

    I had your solution as part of our crm 2011 online. I am wondering whether there will be any issue to it in the coming update . I am yet to update our organization. have anyone tried it .
    please advise. thanks in advance

    • patrick says:

      I am in CRM2013 latest rollup. A few issues lead me to believe it doesn’t work. I spent a few more hours getting it to appear as it is working, but it doesn’t. The big issue is that it isn’t saving the data. Second issue is that it won’t list alphabetically like the option’s list is.

  31. patrick says:

    4 hours later, I surrender. This is not working and the instructions are missing significant details. Please change the headline of this article to NOT include “non-technical”.

    • pearse says:

      To whoever this solution is not working in the new update 2013, I would suggest import the solution and select overwrite the customization while doing so . it is working like a charm now.
      thanks for the awesome solution!

  32. pearse says:

    Thanks Patrick to letting us know.

  33. Jacqueline says:

    Hi, I have placed this solution on my Accounts form for several different fields. I’m getting an error now when I try to merge records. Is this a symptom of the solution?

  34. Andrea says:

    I also tried this in CRM 2013 and as of UR 1, it was working today. Great job on this!!

    • pearse says:

      Andrea, did u do any modification at all? for some it is not working. I am yet to update my crm organization to the new one. is there anything I need to do before the update? I have it installed and working now. but not sure after the update. please advise. thanks in advance!

  35. Hello! I have loaded the solution and have followed all the instructions listed in this post (and referenced the earlier post) and cannot get this to work as per your instructions and the notes listed in the comments. I am running and instance of CRM 2013. Also, why would you use this solution vs. the approach outlined on the forceworks.com site or in the case of a multi selection for contact roles, why not use “connections” to apply multiple values to an entity?

    Regarding not getting this to work, I am getting a “There is an error with this field’s customize event. Onload error undefined”.

    • Got this to work as I mixed up the configuration between part 1 and part 2 (like most of the others i gather… my bad). I am running on CRM 2013 Online. I am testing with IE 10 and Chrome. Learning interesting do’s and dont’s and running through some test scenarios.

      • Looks like there is a bunch more code that has to be included to support Ctrl+> and the “Next Record” UI control when stepping through contacts. I assumed that would work. If you don’t actually save the record, and use Ctrl+> or the “Next Record” arrow the selections don’t save…

  36. céline says:

    This solution is not works correctly on IE8,In fact, the first label is shift below and the last is missing. Someone know how to make it compatible?
    Thank you very much

  37. pearse says:

    Just Wondering , there is no onload function for this. thanks

  38. pearse says:

    Anybody having problem with save button working along with this solution. when I select items in multiple option field and hit save button(on the right bottom of screen) then it doesn’t seem to save but if I go to another opportunity and come back it is saved

  39. steve says:

    This is a great little tool which I’ve implemented for a couple of sites. One thing – I think a couple of other comments have already mentioned this – the multi select uses the option set values: if you need to add new lines to an option set they will show at the bottom of your list (regardless of how you sort the field) – unless you had the forethought (hindsight is a wonderful thing) to manually number them to cater for non-linear additions. I would love to be able to fix the first implementation – is it possible at all?

  40. Dennis says:

    Installed 2013 rollup 2 on my test system and now when creating an opportunity from the account screen I get:

    There was an error with the field’s customized event

    field:crmForm

    Event:onsave

    Error: Object doesn’t support property or method ‘saveMultiSelect’

  41. Dennis says:

    Ok I have some detail. When I open an opportunity from the account screen the error comes up, but only the 1st time I open the opportunity. If I close it and open it again from the account screen I don’t get an error. Also, if I create a new opportunity from the opportunity list I don’t get the error. Seems like the only time it comes up is creating it from the account screen and it only happens one time.

  42. Dennis says:

    I backed out rollup 2 and still having the same issue.

  43. emanefo says:

    Our CRM was finally updated 2 days ago and for cases, we keep getting this error message:

    There was an error with this field’s custumized event.
    Field: custumerid

    Event: Onchange

    Error:Undifined

    I have been looking through the web and there have been a couple of suggestions.

    The error message is quite annoying since it keeps coming up every time the support case.

    I really appreciate for any opinion!

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

%d bloggers like this: