Present Different Drop Downs Based on User Input

Does anyone know how I would go about presenting different values prior to account creation based on options being selected during the creation of the account. For example, in the Web Interface, we go to create a new user and we present them with a list of 5 countries / regions. (USA, UK, MX, JP, Other). This can be achieved via a provisioning policy but when they select USA, I want them to be given a specific list to pick from for the appropriate City. I don't want to list all the cities for every other region. Any guidance on how to achieve this would be great.

Parents
  • Hi Josh

    Bound lists is what you're looking for, have a look at this KB How to create a Bound List-box with 4 Levels (4244019)

    The below script is attached to that KB

    # Source: https://support.oneidentity.com/active-roles/kb/4244019/how-to-create-a-bound-list-box-with-4-levels
    #
    # Active Roles includes an SDK (Software Developer Kit).
    # This is installed by default with Active Roles and can be found in the Start Menu:
    # #
    # To find a related example in the SDK, search for:
    # Example: Creating bound list-boxes
    #
    # The included example shows a 3 level Bound List Box. 
    # This script shows a 4 level Bound List Box
    #
    # THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 
    # INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE
    #
    #
    function onGetEffectivePolicy($Request)
    {
        $level1 = GetCurrentValue $Request 'edsvaLevel1'
        $level2 = GetCurrentValue $Request 'edsvaLevel2'
        $level3 = GetCurrentValue $Request 'edsvaLevel3'
        $level4 = GetCurrentValue $Request 'edsvaLevel4'
    
    
        $level1PossibleValues = @('Plants', 'Animals')
        switch($level1)
        {
            'Plants'   { $level2PossibleValues = @( 'Conifers', 'Flowering plants' ) }
            'Animals'  { $level2PossibleValues = @( 'Insects', 'Fishes', 'Birds', 'Mammals' ) }
            default    { $level2PossibleValues = @( '-', '-' ) }
        }
       
        switch($level2)
        {
            'Conifers'         { $level3PossibleValues = @( 'Pine', 'Spruce' ) }
            'Flowering plants' { $level3PossibleValues = @( 'Oak', 'Birch' ) }
            'Insects'          { $level3PossibleValues = @( 'Flies', 'Butterflies', 'Dragonflies' ) }
            'Fishes'           { $level3PossibleValues = @( 'Sharks', 'Sea fishes', 'River fishes' ) }
            'Birds'            { $level3PossibleValues = @( '-', '-' ) }
            'Mammals'          { $level3PossibleValues = @( 'Predators' ) }
            default            { $level3PossibleValues = @( '-', '-' ) }
        }
    
        switch($level3)
        {
            'Flies'        { $level4PossibleValues = @( 'Black-winged fly', 'Red-tailed fly') }
            'Butterflies'  { $level4PossibleValues = @( 'Machaon', 'Death head moth', 'Gypsy moth', 'Monarch butterfly') }
            'Dragonflies'  { $level4PossibleValues = @( 'Common darter', 'Scarlet dragonfly') }
            'Sharks'       { $level4PossibleValues = @( 'Great white shark', 'Scalloped huummerhead') }
            'Sea fishes'   { $level4PossibleValues = @( 'Tuna', 'Swordfish' ) }
            'River fishes' { $level4PossibleValues = @( 'Pike', 'Carp', 'Goldfish') }
            'Predators'    { $level4PossibleValues = @( 'Wolf', 'Tiger', 'Lion', 'Cat') }
            default        { $level4PossibleValues = @( '-', '-' ) }
        }
        
        $Request.SetEffectivePolicyInfo('edsvaLevel1', $Constants.EDS_EPI_UI_POSSIBLE_VALUES, [string[]]$level1PossibleValues) 
        $Request.SetEffectivePolicyInfo('edsvaLevel2', $Constants.EDS_EPI_UI_POSSIBLE_VALUES, [string[]]$level2PossibleValues) 
        $Request.SetEffectivePolicyInfo('edsvaLevel3', $Constants.EDS_EPI_UI_POSSIBLE_VALUES, [string[]]$level3PossibleValues) 
        $Request.SetEffectivePolicyInfo('edsvaLevel4', $Constants.EDS_EPI_UI_POSSIBLE_VALUES, [string[]]$level4PossibleValues) 
    
        $Request.SetEffectivePolicyInfo('edsvaLevel2', $Constants.EDS_EPI_UI_RELOAD_EPI_BY_RULE, 'edsvaLevel1')
        $Request.SetEffectivePolicyInfo('edsvaLevel3', $Constants.EDS_EPI_UI_RELOAD_EPI_BY_RULE, 'edsvaLevel2')
        $Request.SetEffectivePolicyInfo('edsvaLevel4', $Constants.EDS_EPI_UI_RELOAD_EPI_BY_RULE, 'edsvaLevel3')
    
        $Request.SetEffectivePolicyInfo('edsvaLevel1', $Constants.EDS_EPI_UI_RESTRICTED , $true) 
        $Request.SetEffectivePolicyInfo('edsvaLevel2', $Constants.EDS_EPI_UI_RESTRICTED , $true) 
        $Request.SetEffectivePolicyInfo('edsvaLevel3', $Constants.EDS_EPI_UI_RESTRICTED , $true) 
        $Request.SetEffectivePolicyInfo('edsvaLevel4', $Constants.EDS_EPI_UI_RESTRICTED , $true) 
    
    }
    
    function GetCurrentValue($Request, [string]$AttributeName)
    {   
        trap {continue}
        $value = $Request.Get($AttributeName)
        if($value -eq $null)
        {
            $DirObj.GetInfoEx(@($AttributeName),0) | Out-Null
            $value = $DirObj.Get($AttributeName)
        }
        $value
    }

    The above script is in essence a scripted "property validation and generation rule" (granted without the validation part).

    The arrays within the script $Level1PossibleValues, $Level2PossibleValues, $Level3PossibleValues and $Level4PossibleValues are populated with values as per the value currently set in the higher level, meaning initially the possible values for Param1 is Plants or Animal, but Params 2, 3 & 4 would be - or -

    If Param1 is set to Animals, Param2 would have the option for Insects, Fishes, Birds and Mammals, but Params 3 and 4 would be - or -

    When Param 1 is Animals, Param2 is Mammals, Param3 would show only predators, and Param4 would be - or -

    When predators for Param3, param 4 would offer Wolf, Tiger, Lion or Cat.

    However hardcoding in the script is not ideal, you'd be better to have a CSV or some other data source, where you can populate the arrays with the values you want, depending on the previous levels selected item.

    That could be a single CSV with 4 columns, where you select the values for each level like

    $Data = Import-csv "Somefile"
    
    $level1 = GetCurrentValue $Request 'edsvaLevel1'
    $level2 = GetCurrentValue $Request 'edsvaLevel2'
    $level3 = GetCurrentValue $Request 'edsvaLevel3'
    $level4 = GetCurrentValue $Request 'edsvaLevel4'
    
    $Level1PossibleValues = $Data | Select-Object Level1 -unique
    $Level2PossibleValues = $Data.where({(($_.Level1 -eq $Level1) -and ($_.Level2 -eq $Level2))}) | Select-Object Level2 -unique
    $Level3PossibleValues = $Data.where({(($_.Level1 -eq $Level1) -and ($_.Level2 -eq $Level2) -and ($_.Level3 -eq $Level3))}) | Select-Object Level3 -unique
    $Level4PossibleValues = $Data.where({(($_.Level1 -eq $Level1) -and ($_.Level2 -eq $Level2) -and ($_.Level3 -eq $Level3) -and ($_.Level4 -eq $Level4))}) | Select-Object Level4 -unique

    Level1 Level2 Level3 Level4
    Animals Mammals Predators Wolf
    Animals Mammals Predators Tiger
    Animals Mammals Predators Lion
    Animals Mammals Predators Cat
    Animals Fishes Sharks Great white shark
    Animals Fishes Sharks Scalloped huummerhead
    Animals Fishes Sea fishes Tuna Swordfish
    etc etc etc etc
    etc etc etc etc

    Hope that helps

    Stu

  • Thanks Stu, appreciate the quick response. I will test this out and reply back in a bit.

Reply Children
No Data