Error: The given key was not present in the dictionary
Today I had the following error "The given key was not present in the dictionary" in MS CRM when opening an associated view.
![]()
Searching for a solution I came accross many blogs indicating that plugins might be the cause.
As it turned out I had deleted a picklist option from the entity without reassigning the existing data to a new option value. Thanks to Daniel Cai for pointing me in the right direction.
Dynamically filter a picklist in MS CRM – Part 2
Last year I wrote an article explaining how to filter a picklist based on another picklist in MS CRM. In this article I’ll explain how to filter a picklist based on an array of values. The original idea for this approach came from Greg Owens on: The CRM Grid – A Microsoft CRM Blog.
I made this function a bit more generic, you can simply pass a array of item values to filter your picklist.
Code the code in the Onload event and use the example to filter the picklist:
Read more
Shared Picklists in CRM 2011
Found on CRM Consultancy Blog:
Often when working on CRM Projects we will want to present the user with a drop-down list of options for a field that we would then want to see repeated at different points within the user’s business process – for example we may want a ‘Business Type’ drop down field on all the Sales Entities to describe the type of business intended for the Opportunity, Quote, Order or Invoice within the business, and obviously we would want this drop down field mapped across for any Quotes or Orders resulting from the Opportunity or in turn any Invoices resulting from the Order.
Continue to read this article…
Convert text field to picklist in MS CRM
This function below describes how you can convert a text field into a picklist.This original script was developed by MS CRM 4.0 – Unleashed. I made a few changes to it so you can now save a picklist value while displaying the text. If no text array is passed than the values will be shown.
Read more
How to create a multi select picklist in MS CRM
By default it is not possible to create a multi select picklist in MS CRM. MVP Jim Wang has created an interesting post on how to achieve a checkbox style multi-select using JavaScript and use an extra text field to store the selected picklist items.
In my implementation I just needed to display the multi-select picklist without saving the selected items. I have made the original script a bit more generic so you can use it to both display only or display and save the items. Furthermore, you can now retrieve both the picklist value as well as the selected text (see example 2).
The function requires the following parameters:
- picklist = name of the picklist
- textfield = name of the textfield to store the selected items (Optional).
(if textfield is empty, the items will not be saved and the checkboxes will only be displayed. Use the example below to check which items are selected)
Updates:
| 20110222 GP: | changed function to be able create multiple multi-select picklists on one form AND save each individual selection !! |
Copy the code in the Onload event and use the examples below to call the function:
Dynamically filter a picklist in MS CRM – Part 1
This article explains how to filter a picklist based on another picklist in MS CRM. While most examples to filter picklists use items that are hardcoded in JavaScript, this approach is completely dynamic.
The original idea for this approach came from Greg Owens on: The CRM Grid – A Microsoft CRM Blog.
Solution
The code below filters the second picklist based on the values of the first. More specifically, the values of the second picklist must start with the value of the first picklist. This way users can change the items without having to change the javascript.
Example:
| Picklist 1 (Segment) | Picklist 2 (Sub Segment) |
| 100 Automotive | 1001 Engine |
| 1002 Engine air, fuel | |
| 1003 Chassis and suspension | |
| 102 Connectors | 1021 Auto connector |
| 1022 I/O connector | |
| 1023 Memory Card Connector |
Tip: Make sure you keep the ranges between each item in the first picklist wide enough so people can still add new items.
Please note:
This script calls 3 additional functions also posted on our blog: gLeft(), gLen() and gClearOptionList().
Copy the function below in the OnLoad event. Read more
XML Picklist Generator
There is a tool that allows you to easily generate XML codes for creating picklist values. The generated XML can then be copied directly in the appropriate customization file.
Go to this website: XML-Generator for Picklist-values to use with Microsoft Dynamics CRM.
gListRenameOption()
Use this function to dynamically rename an item in a picklist.
//*********************************************************
gListRenameOption = function(list,optiontext, newtext){
/*
This function is used to rename an option of an optionlist in client-side code
Usage: gListRenameOption(list,optiontext)
Returns: nothing
Author: GP
Dependencies: none
*/
var oList = document.all(list);
var iRename;
for (var l=0;l<oList.options.length;l++){
if(oList.options[l].text==optiontext){
iRename = l;
}
}
oList.options[iRename].text=newtext;
}
gListRemoveOption()
With this you can dynamically remove an item from a picklist in client-side code.
//*********************************************************
gListRemoveOption = function(list,optiontext){
/*
This function is used to remove an option of an optionlist in client-side code
Usage: gListRemoveOption(list,optiontext)
Returns: nothing
Author: GP
Dependencies: none
*/
var oList = document.all(list);
var iDelete;
for (var j=0;j<oList.options.length;j++){
if(oList.options[j].text==optiontext){
iDelete = j;
}
}
if (iDelete>= 0){
oList.options[iDelete] = null;
}
}
gClearOptionList()
This function allows you to clear a picklist in client-side code.
//*********************************************************
gClearOptionList = function(oList){
/*
This function is used to set a clear an optionlist / picklist in client-side code
Usage: gClearOptionList(oList)
Returns: nothing
Author: GP
Dependencies: none
*/
// clear down children
while(oList.options.length>0){
oList.options[0]=null;
}
return;
}

