Guy Riddle's profileMicrosoft Dynamics CRMBlogLists Tools Help

Blog

    May 10

    Dynamic filtering of picklist values

    This is a great technique, especially if you want to base the values of one picklist field based on what a user selected in a previous picklist field.
     
    I have even used a similar technique for controlling data entry for Country, State and Suburb - by simply adding three 'dummy' picklist fields that contain the appropriate values, then using this picklist filtering method; and finally using a small piece of Jscript code to move the value of the dummy picklist field to the 'real' CRM field.
     
    Note - don't replace these address fields completely with picklist fields,  The address fields come up in many places and you will find that you can create issues down the track.
     
    // Set the Country
    var oCountry = crmForm.all.mycountryfield;
    // Initialize the State indexes
    var iStartIndex = -1;
    var iEndIndex = -1;
    // Depending on what Country the user selects we will select
    // a range of options in the State picklist to display.
    //
    // In this example, it is assumed that the display text of each
    // Country will be known; also, all the State values
    // in the State picklist are group sequentially per
    // Country.  This makes coding easier.

    switch (oCountry.SelectedText)
    {
    case "Australia":
    iStartIndex = 1;
    iEndIndex = 8;
    break;
    case "USA":
    iStartIndex = 9;
    iEndIndex = 59;
    // Note - the start/end indexes must relate to the order of the values in the picklist
    break;
    }
    // Set the State
    var oState = crmForm.all.mystatefield;
     
    if (iStartIndex > -1 && iEndIndex > -1)
    {
    // Create an array to hold the picklist values
    var oTempArray = new Array();
    // Initialise the array index
    var iIndex = 0;
    // Read the State options and move only the
    // requested options into the array.
    for (var i = iStartIndex; i <= iEndIndex; i++)
    {
    oTempArray[iIndex] = oState.originalPicklistOptions[i];
    iIndex++;
    }
    // Reset the State picklist with the new options
    oState.Options = oTempArray;
    // Enable the State picklist for the user
    oState.Disabled = false;
    }
    else
    {
    // If there is no State
    oState.DataValue = null;
    oState.Disabled = true;
    }
     

    Comments (7)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    No namewrote:
    货架 =>超市货架,北京货架,仓储货架,货架网,货架厂。 超市货架 =>超市货架尺寸,超市货架效果图,杭州超市货架,超市货架摆放,广州超市货架。 北京货架 =>北京货架批发市场,北京货架厂家,北京货架制作,北京货架价格,北京货架销售。 仓储货架 =>仓储货架厂,北京仓储货架,苏州仓储货架,无锡仓储货架,广州仓储货架。 货架网 =>中国货架网,我要货架网,中国超市货架网,全球货架网,苏州货架网。 货架厂 =>佛山货架厂,天津货架厂,成都货架厂,常熟货架厂,服装货架厂。 南京货架 =>南京货架厂,南京货架网,南京货架公司,南京货架制造厂,南京货架价格。 仓库货架 =>仓库货架厂,北京仓库货架,无锡仓库货架,深圳仓库货架,广州仓库货架。 广州货架 =>广州货架厂,广州货架批发市场,广州货架公司,广州货架市场,广州货架制作。 塑料托盘 =>塑料托盘价格,北京塑料托盘,求购塑料托盘,武汉塑料托盘,塑料托盘制造商。 木托盘 =>木托盘标准,木托盘价格,塑木托盘,熏蒸木托盘,求购木托盘。 仓储笼 =>南京仓储笼,求购仓储笼,折叠式仓储笼,苏州仓储笼,无锡仓储笼。 购物车 =>购物车图标,购物车原理,购物车设计,购物车图片,超市购物车。 托盘车 =>手动液压托盘车,液压托盘车,电动托盘车,手动托盘车,全电动托盘车。 工具柜 =>工具柜价格,天钢工具柜,北京工具柜,安全工具柜,苏州工具柜。 工作台 =>超净工作台,防静电工作台,净化工作台,回转工作台,超净工作台价格。 升降平台 =>液压升降平台,铝合金升降平台,电动升降平台,残疾人升降平台,升降平台车。 升降台 =>铝合金升降台,电动升降台,立式升降台铣床,万能升降台铣床,手动升降台。 登车桥 =>沈阳登车桥,沈阳液压登车桥,固定式登车桥,天津登车桥,移动液压登车桥。 升降机 =>液压升降机,施工升降机,铝合金升降机,丝杆升降机,汽车升降机。
    Oct. 20
    No namewrote:
    Welcome to enter (wow gold) and (wow power leveling) trading site, (Rolex) are cheap, (World of Warcraft gold) credibility Very good! Quickly into the next single! Key words directly to the website click on transactions!
    Aug. 20
    No namewrote:
    Hi,
     
    I just want to ask regaring the picklist selection of State. I have 2 fields 1 for picklist selection of states in australia (WA, SA, ACT, TAS, QLD, Others). Id user select the "Others", my next field will be enabled for the user to enter different state which is not n the currect selection. That means be default my Other field is disabled, it will only enable when user select the "Others".
     
    Hope you can help me on this.
     
    Thanks  
    Aug. 24
    No namewrote:
    Hi,
     
    I just want to ask regaring the picklist selection of State. I have 2 fields 1 for picklist selection of states in australia (WA, SA, ACT, TAS, QLD, Others). Id user select the "Others", my next field will be enabled for the user to enter different state which is not n the currect selection. That means be default my Other field is disabled, it will only enable when user select the "Others".
     
    Hope you can help me on this.
     
    Thanks  
    Aug. 24
    Picture of Anonymous
    Degremont wrote:
    Ok, my issue is resolved.
     
     
    See you.
     
    Aug. 1
    Picture of Anonymous
    Degremont wrote:

    The error was as following "An error occurred when populating Microsoft CRM"can  tell me if 'originalPicklistOptions is this really valid for a picklist.

     

    Thanks for you help,

    Best regards.

    Michel DEGREMONT?.

    July 25
    Picture of Anonymous
    Degremont wrote:
    Hi,
     
    I work with CRM 3.0, and when I want to use "originalPicklistOptions" I have a custom error.
     
    "originalPicklistOptions" doesn't exist.
     
     
    July 25

    Trackbacks (0)

    The trackback URL for this entry is:
    http://guyriddle.spaces.live.com/blog/cns!5D4E0DC4D1513384!126.trak
    Weblogs that reference this entry
    • None