Home     |     MS SQL Server    |     MS SharePoint    |     MS Visual Studio    |     MS Certifications    |     MS CRM     |     MS Office    |     MSF


Cervo Technologies
The Right Source to Outsource

microsoft.public.crm

Dynamic Picklist bug


I've installed the Dynamic Picklist from the CRM 3.0 SDK.  I've installed it
directly as well as created a separate entity and re-created it there and
copy/pasted edited Jscript into the new entity so that it works with my field
names and my drop-down picklist items.

They both work just fine (the original default test entity as well as my
edited entity) with one fairly major bug.  On either entity when you select
your Industry it pulls the correct index for subindustry and displays these
for the user to select from.  When the user selects the desired Sub-industry,
it indeed enters the correct information in both fields.  Once you save the
record the correct information is stored.  

Here is the problem, once the record is opened again the Industry contains
the correct text, the Sub-industry field incorrectly displays the text from
the top of the index.  

As an example, in the default test installation of the Dynamic Picklist
component, if Accounting were selected as the Industry type and Tax Returns
selected as the Sub-industry type the record would be stored in this way.  
When reentering the record Industry would display as Accounting but
Sub-industry would display as Auditing. If you close out of the record
without saving of course the Sub-industry field still contains Tax Returns
but any time you enter the record it displays the incorrect information and
of course the possibility always exists that the user could save and modify
the record with the incorrect Sub-industry information.

Have you seen this before, I've got to think that this is going to happen
for everyone as it happens with the default code in a default installation
without any modification whatsoever.  I guess there could also be a problem
with my CRM installation.  I'm not sure, I'm going to try this on another PC
as well as the problem may be due to the fact that I'm running a Vista
client.  I'll try this on a Windows XP box as well and see if I get the same
problem.  I just wanted to see if anyone has seen this before.

Yes, they didn't provide a complete example.:)  what you have to do it
to write some other javascripts to keep track of the selected values,
then on the form load event, retrieve those values and assign it back
to the pick list.

Darren Liu
Crowe Chizek and Company
http://www.crowecrm.com

On May 11, 8:25 am, DHorn <D@discussions.microsoft.com> wrote:

Many thanks,

For future reference of others with this same problem, it can be corrected
in the code by adding two lines of code to the default OnChange script.

Below is the corrected default OnChange script.

// Get the Industry Element, since this event was fired by this element; the
// event's "Source Element" will contain a reference to it.
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;

}

// Get a reference to the Sub-Industry picklist element for later use
var oSubIndustry = crmForm.all.new_subindustry;
var currentValue = oSubIndustry.DataValue;

// 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;
oSubIndustry.DataValue = currentValue;
// 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;

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc