Resources for IT Professionals > Dynamics Forums > CRM Development > Editing dynamic picklist values
Ask a questionAsk a question
 

AnswerEditing dynamic picklist values

  • Tuesday, November 13, 2007 7:12 AMnaazg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Dear Experts,

     

    A month back I asked a question regarding dynamic picklist value. I installed SDK and I found the example I used that code and its working perfectly. As per the SDK.

     

    In that example we have 2 picklist industry and sub industry. The example work with ID. subindustry 1-5 is the industry value for A and 6-12 is the industry B values.

     

    I am using this for Region and Cities.. I have 5 Region and each region contain many cities. Lets say central, westren, southern. At the initail stages I added all the regions and values against them. let say my Region A is having 15 cities and region B is having 10 Cities. I use the SDK sample and us the FOR loop. if some1 select A the loop run from 1 to 15 and if he select B the loop start from 16 till the 26 and so on with the other region. Suppose in future if i need to add another city in Region A. What i have to do. I need to modify each and every values again. Is it possible i can give gap between them for future. Let say I would like my region A start from 1 and end at 15 and I would like to start the region B from 50 onward so in future if i want to add another cities in region A i can assign a value 16 and change the loop from 1 to 16 instead of 1- 15.

     

    your prompt advise is highly appreciated. Do let me know if i am going in a wrong direction and if there is any simple solution for it.

     

    Regards,

    Naaz

Answers

  • Tuesday, November 13, 2007 12:23 PMuMar Khan [MVP]MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

    There is no possiblity to skip few numbers in between but there is another workaround. You may add 5 or lets say 10 extra values in picklist for each regdion as city. Once you have any new city you can just replace one of those empty city values with this new city name.

  • Tuesday, November 13, 2007 3:28 PMuMar Khan [MVP]MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

    Yes, it is going to work but the issue is that data will not remain consistent after the change in the account entity. The existing recrods will have old picklist values. The new picklist will have same city names but different city values as compared to old data.

  • Wednesday, November 14, 2007 10:09 AMuMar Khan [MVP]MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Naazg,

    Now you are talking Smile Your idea is exactly what i am trying to suggest in my first post. This is the way I work.

     

    How can data be not consisitent: Sorry for not explaining my point in detail. This statment is for another scenario. Let me give you an example. You have 3 values.

     

    1, CityA

    2, CityB

    3, CityC

     

    For few weeks its like that. That is entered in CRM. Then comes a new requirment to add another city CityD after CityA. You cannot do it with CRM interface but if you open the customization file and edit it directly and import it again then it will work but inconsisten. Following is example

     

    1, CityA

    2, CityD

    3, CityB

    4, CityC

     

    Now old records which have previously CityB with value 2  will not be pointing to CityD with value 2. New records will have conssitent data.

All Replies

  • Tuesday, November 13, 2007 12:23 PMuMar Khan [MVP]MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

    There is no possiblity to skip few numbers in between but there is another workaround. You may add 5 or lets say 10 extra values in picklist for each regdion as city. Once you have any new city you can just replace one of those empty city values with this new city name.

  • Tuesday, November 13, 2007 1:56 PMnaazg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Dear Umar,

     

    Thanks for the reply. I think its possible. what if i export the customization and open the xml file and change the id's manaully. and then reimport the customization. is it gonna work.

     

    Is there any other way to create a dynamic list or the one which is mentioned in SDK is the only way.

     

    Regards,

    Naaz

     

     

     

  • Tuesday, November 13, 2007 2:15 PMGreg Owens Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Naaz

     

    Take a look at the blog posting that I've just put up, inspired by your question Wink

     

    Hope it is helpful, but be aware I've just whacked this together in my lunchbreak so it is untested until I get near a CRM server!

  • Tuesday, November 13, 2007 3:28 PMuMar Khan [MVP]MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi,

    Yes, it is going to work but the issue is that data will not remain consistent after the change in the account entity. The existing recrods will have old picklist values. The new picklist will have same city names but different city values as compared to old data.

  • Wednesday, November 14, 2007 7:17 AMnaazg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    HI Greg & Umar,

     

    Let me try to code sent by Greg. I had a problem with it. suppose if i have 1000's of cities. it will be time consuming. or lets see the example of companies and its related products. well I will update you all.

     

    Regarding Umar I am sorry i disagree with you. how can you say the data is not consistent. I will use 1 - 50 for region A but my loop will run only 1 to 15 and will update the value 1 to 15. if in future i add another one then my loop will run 1 - 16 and data will be available from 1 - 16. well i will try both. in the table the account will have id's if for old record some1 select 1 it will be still one as i am increasing at the last.

     

    Thanks,
    Naaz

  • Wednesday, November 14, 2007 10:09 AMuMar Khan [MVP]MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Naazg,

    Now you are talking Smile Your idea is exactly what i am trying to suggest in my first post. This is the way I work.

     

    How can data be not consisitent: Sorry for not explaining my point in detail. This statment is for another scenario. Let me give you an example. You have 3 values.

     

    1, CityA

    2, CityB

    3, CityC

     

    For few weeks its like that. That is entered in CRM. Then comes a new requirment to add another city CityD after CityA. You cannot do it with CRM interface but if you open the customization file and edit it directly and import it again then it will work but inconsisten. Following is example

     

    1, CityA

    2, CityD

    3, CityB

    4, CityC

     

    Now old records which have previously CityB with value 2  will not be pointing to CityD with value 2. New records will have conssitent data.

  • Wednesday, November 14, 2007 11:07 AMnaazg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Dear Umar,

     

    in that case you are correct but my case is not After CITYA. I can even add it at the last. i have cities starting from 1 - 15 which belongs to regionA and i can assign the new city to 16 not between 1-15. so whenever some1 select regionA he will get the list of Cities.. 1 - 16 and that number will be included.

     

    Have you tried the way Mr. Greg mentioned ?

     

    Regard,

    Naaz

     

  • Thursday, December 06, 2007 9:08 AMnaazg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Dear Greg,

     

    I am trying to use your code which seems excellent. but i am stuck at one point. i don't know where is the error..its says oCity[...].value is null or not an object. The red link i mention. I tried to check by passing static value its working.. Could you please help me as soon as possible.

     

    if(oCityIdea.value == oDesiredOptions[j])

     

    Regards,

    Naaaz

     

     

     

    var oRegion = crmForm.all.naz_region;
    var oCity = crmForm.all.naz_city;

    // keep a copy of the original options and reset the picklist before we start firking about
    if(!oCity.originalPicklistValues)
    {
    oCity.originalPicklistValues = oCity.Options;
    }
    else
    {
    oCity.Options = oCity.originalPicklistValues;
    }

    // create an array to hold the required picklist values for each category
    var oArrayCentral = new Array();
    var oArrayEastern = new Array();
    var oArraySouthern = new Array();
    var oArrayWestern = new Array();
    var oArrayNorthern = new Array();


    // *** This is the bit you would edit to add/remove options to your lists *** //
    oArrayCentral.push(2,13);
    oArrayEastern.push(1,6,10,14,17,18,19,20);
    oArraySouthern.push(1,2,3,4,7,8,9,11,13,14,15,16,19);
    oArrayWestern.push(5,12,17,18);
    oArrayNorthern.push(22,23,24,26);

     

    // *** No more editing *** //
    // Now call the appropriate filtering parameters
    if(oRegion.DataValue != null)
    {
    switch(oRegion.SelectedText)
    {
    case "Central Region":
    filterPicklist(oArrayCentral);
    break;

    case "Eastern Region":
    filterPicklist(oArrayEastern);
    break;

    case "Northern Region":
    filterPicklist(oArrayNorthern);
    break;

    case "Southern Region":
    filterPicklist(oArraySouthern);
    break;

    case "Western Region":
    filterPicklist(oArrayWestern);
    break;
    }
    }

    function filterPicklist(oDesiredOptions)
    {
    var oTempArray = new Array();

    // loop through all items in the master list
    for (var i=oCity.length;i >= 0;i--)
    {
    // if the option value is in the list of desired values for this colourgroup
    // then add the option to our temp array and remove the
    // item from the desired option array
    for (j=oDesiredOptions.length;j >= 0;j--)
    {
    if(oCityIdea.value == oDesiredOptions[j])
    {
    oTempArrayIdea = true;
    oDesiredOptions.splice(j,1);
    }
    }
    }

    // Now remove all options from the master list that were not marked as required
    for (var i=oCity.length;i >= 0;i–)
    {
    if(oTempArrayIdea != true)
    {
    oCity.remove(i)
    }
    }
    }

  • Thursday, June 05, 2008 1:59 PMNAG_MSCRM Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Dear Naaz,

     

    I imported same example into MS CRM 4.0. How to re-use this dynamic picklist in the Leads/Accounts Form. What is the procedure? Where can i found this type of customizations ? Could u please help me out in this issue.

     

    Thanks & Regards,

     

    Nagendra.