domingo, 15 de septiembre de 2013

CRM 4.0 - Picklist relacionados y limitados por rango (sacado de otro blog)

PICKLIST ET RELATIONSHIP
Clark [MVP CRM] posted on Wednesday, November 26, 2008 8:28 AM

Bonjour
J'ai trouvé ça à cet endroit :
https://community.dynamics.com/forums/t/6337.aspx
Je n'ai pas testé mais ça m'a l'air de pouvoir fonctionner.
Chained Picklist Sample
//Form on load event
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
// Only enable the dynamic picklist on a Create or Update form.  Disabled
and
// read-only forms are not editable and so do not require dynamic picklists.
switch (crmForm.FormType)
{
case CRM_FORM_TYPE_CREATE:
case CRM_FORM_TYPE_UPDATE:
// Get a reference to the Sub-Industry picklist element for later use
var oSubIndustry = crmForm.all.new_subindustry;
// Cache the original picklist "Options" array in an "expando" on the
// element.  We will use this original list to dynamicly re-build the
picklist
// based on the Industry the user selects.
oSubIndustry.originalPicklistOptions = oSubIndustry.Options;
// If there is not an Industry selected, we just need to disable the
// Sub-Industry.  As soon as the user selects an Industry, we will
// re-enable the Sub-Industry picklist.
if (crmForm.all.new_industry.DataValue == null)
{
oSubIndustry.Disabled = true;
}
else
{
// There is a value already selected, we need to limit the available
options
// to what is valid for the currently selected Industry value.  The code
to
// do this already exists in the Industry Picklist's onchange event.  We
will
// re-use this code by manually firing the event.
new_industry_onchange0();
}
break;
}

// Get the Industry Element, since this code is re-used by the form's onload
event
// we can not rely on the event.srcElement to have the approriate element.
var oIndustry = crmForm.all.new_industry;
// Initialize the Sub-Industry indexes
var iStartIndex = -1;
var iEndIndex = -1;
// Depending on what the user selects in the Industry picklist, we will
select
// a range of options in the Sub-Industry picklist to display.
//
// For the purposes of this sample, it is assumed that the display text of
each
// Industry will be known and will not be localized.  We have also ordered
the
// options in the Sub-Industry picklist so that they are group sequentially
per
// Industry.  This allows the code to simply define start and stop
Sub-Industry
// indexes for each Industry.
switch (oIndustry.SelectedText)
{
case "Accounting":
iStartIndex = 1;
iEndIndex = 5;
break;
case "Consulting":
iStartIndex = 6;
iEndIndex = 10;
break;
}

//Picklist ONChange event
// Get a reference to the Sub-Industry picklist element for later use

var oSubIndustry = crmForm.all.new_subindustry;
// If the indexes where set, update the Sub-Industry picklist
if (iStartIndex > -1 && iEndIndex > -1)
{

// Create a new array, which will hold the new picklist options
var oTempArray = new Array();
// Initialize the index for the temp array
var iIndex = 0;
// Now loop through the original Sub-Industry options, pull out the
// requested options a copy them into the temporary array.

for (var i = iStartIndex; i <= iEndIndex; i++)
{
oTempArray[iIndex] = oSubIndustry.originalPicklistOptions[i];
iIndex++;
}
// Reset the Sub-Industry picklist with the new options
oSubIndustry.Options = oTempArray;

// Enable the Sub-Industry picklist for the user
oSubIndustry.Disabled = false;

}
else
{
// The user has selected an unsupported Industry or no Industry
oSubIndustry.DataValue = null;
oSubIndustry.Disabled = true;
}
23d2b4ff-9764-4a3c-a9db-2d3b634c3f67@x8g2000yqk.googlegroups.com...

Bonjour,
Je cherche à créer une liste déroulante dont les valeurs vont dépendre
d'une première liste
déroulante , par exemple Catégorie 1 : légume > catégorie 2 :
carottes , choux , etc..
Merci pour vos idées.
Ben

No hay comentarios:

Publicar un comentario