Tras varios artículos sobre CRM 2011, volvemos a la ‘realidad’ actual, es decir, a CRM 4.0. A continuación os describo un desarrollo que realice hace un tiempo basado en el artículo CRM 4.0: Checkbox style Multi-Select Picklist. En ese artículo se muestra un código excelente para crear un control relacionado con un picklist que permite una selección múltiple. Los valores seleccionados en el cuadro de multiselección (creados a partir de los valores de un picklist) se almacenan en un atributo de texto.
Para implementar este control debemos proceder del siguiente modo:
1. Crear el atributo picklist que contendrá las opciones disponibles (en este ejemplo, new_departamento) en la entidad que queramos añadir el control (en el ejemplo (systemuser)
2. Crear un atributo de tipo nvarchar(100) que contendrá los valores seleccionados (en este ejemplo, new_departamentovalor)
3. Añadir el siguiente código al evento OnLoad de la entidad cuyo formulario queramos añadir el nuevo control de multiselección:
[sourcecode language="javascript"]
// Funciones para ocultar un atributo
function HideItem(fieldName)
{
var obj = document.getElementById(fieldName);
if (obj != null)
{
obj.style.display = ‘none’;
}
}
function HideField(fieldName)
{
HideItem(fieldName);
HideItem(fieldName + "_c");
HideItem(fieldName + "_d");
}</span>
// Crea picklist multivalue
function MultiValuePickList(PL, PLV)
{
if( PL != null && PLV != null )
{
crmForm.attachEvent( "onsave" , MVPLOnSave = function()
{
PLV.value = "";
var getInput = PL.nextSibling.getElementsByTagName("input");
for( var i = 0; i < getInput.length; i++ )
{
if (getInput[i].checked)
{
PLV.value += getInput[i].id + "||";
PLV.value += getInput[i].nextSibling.innerText + "||";
}
}
}
);
PL.style.display = "none";
PLV.style.display = "none";
// Create a DIV container
var addDiv = document.createElement("<div id=’MVP’ style=’overflow-y:auto; height:80px; border:1px #6699cc solid; background-color:#ffffff;’ />");
PL.parentNode.appendChild(addDiv);
// Initialise checkbox controls
for( var i = 1; i < PL.options.length; i++ )
{
var pOption = PL.options[i];
if( !MVPLIsChecked(PLV, pOption.value) )
var addInput = document.createElement("<input id=’" + pOption.value + "’ type=’checkbox’ style=’border:none; width:25px; align:left;’ />" );
else
var addInput = document.createElement("<input id=’" + pOption.value + "’ type=’checkbox’ checked=’checked’ style=’border:none; width:25px; align:left;’ />" );
var addLabel = document.createElement( "<label />");
addLabel.innerText = pOption.text;
var addBr = document.createElement("<BR>");
PL.nextSibling.appendChild(addInput);
PL.nextSibling.appendChild(addLabel);
PL.nextSibling.appendChild(addBr);
}
}
}
// Check if it is selected
function MVPLIsChecked(PLV, pText)
{
if(PLV.value != "")
{
var PLVT = PLV.value.split("||");
for( var i = 0; i < PLVT.length; i++ )
{
if( PLVT[i] == pText )
return true;
}
}
return false;
}
// Crea picklist multivalor para la selección de Departamento
MultiValuePickList(crmForm.all.new_departamento, crmForm.all.new_departamentovalor);
HideField("new_departamentovalor");
[/sourcecode]
4. Guardar y publicar el formulario
Tras realizar los pasos anteriores observaremos que al abrir el formulario de detalle de un registro (en el ejemplo, de un usuario) se mostrará un nuevo control que nos permite seleccionar varios elementos de un picklist:
Como más de uno habrá pensado ya, este sistema es muy práctico para la introducción y gestión de los multivalores, sin embargo, a la hora de realizar búsquedas avanzadas, deberemos buscar por el valor (o el texto del picklist, si modificamos el código) sin poder seleccionar varias opciones del picklist para la búsqueda.

There is something like this for version 2011??, I urge
I’m gone to convey my little brother, that he should also pay a quick visit this webpage on regular basis to take updated from most up-to-date information.
If some one wants to be updated with latest technologies afterward he must be pay a visit this site and be up
to date everyday.
It’s hard to find experienced people about this topic, but you sound like you know what you’re talking about!
Thanks
Hi, can any body assist me how to get this video tutorial from
this web site, I have watched and listen it
at this time but would like to down load it.
Eѵeryone lovеs what уou guуs tenԁ tο be uρ too.
This tуpe οf clеver wоrk and exposurе!
Keep up thе supeгb wοrks guyѕ Ӏ’ve incorporated you guys to our blogroll. http://www.tinnitus411.com/clear-tinnitus/