Can I generate a value based on user input

We have a need for an admin to input an 8-digit code into a virtual attribute named "Challenge" on a user form, run that code through a "generator.exe" on the Active Roles server, then display it in another virtual attribute named "Response".  At this point, when i hit "Save", I can run whatever a user types into the Challenge attribute through the generator.exe and return the "response" code in an error on the red banner or even a policy compliance error near the attribute, but I would love to refresh the form within the Response code in the Response virtual attribute on the form. If there is a way to get the value the user typed into the Challenge attribute and process it without hitting Save and having to re-open the user to see the written response code in the Response virtual attribute, that is what I'm looking for.

I've tried various ways in onGetEffectivePolicy and onCheckPropertyValues and onPreModify, but I can only seem to get the code to display in the WebUI if I write the response code to the Response virtual attribute then re-open the user and see it, or if i throw an error with it.  Anyone have any ideas?

  • Hopefully this code will help point you in the right direction. It will create a generate button next to the Response VA, much like the button next to samAccountName when generation rules are in place. Adjust the attribute names of the two variables at the top of the script, and obviously run the necessary code within the function to generate the proper Response value.

    function onGetEffectivePolicy($Request)
    {
       if ($Request.Class -ne "user") {return}
    
       # Get the value from this attribute that has been entered on the AR interface
       $Value = $Request.Get('edsvaChallenge')
    
       # Set the attribute name affected by this policy script
       $strAttrName = "edsvaResponse"
       
       # Call the function to generate the response value   
       $ResponseValue = GenerateValue $Value
       
       # Set policies on the attribute that will display the calculated/computed value and display the lightning bolt button next to it
       $Request.SetEffectivePolicyInfo($strAttrName, $Constants.EDS_EPI_UI_DISPLAY_NOTE, "Computed value based on Challenge VA entry")
       $Request.SetEffectivePolicyInfo($strAttrName, $Constants.EDS_EPI_UI_SERVER_SIDE_GENERATED, $ResponseValue)
       $Request.SetEffectivePolicyInfo($strAttrName, $Constants.EDS_EPI_UI_GENERATED_VALUE, $ResponseValue)
    }
    
    function GenerateValue ($Value)
    {
       # Run code here that takes the inputted value from the AR interface
    
       # Example returning values when lightning bolt button is clicked
       if ($Value -eq "12345678")
       {
          return "ABCD"
       }
       else
       {
          # Return something else
          return "Please enter 12345678"
       }
    }

  • Actually, one more question.  If I wanted to validate what was entered in edsvaChallenge when that button is clicked, where would that code fit best? (ie. check for 8 digits, etc.) Because the first time it checks policy it will be blank, but when i click the button is when i want to check.

  • I've done something similar with a check box on the web page that was along the lines of "are you sure". I would return a message in the Response field that tells the user more information like "please check the box to continue". All of that validation code was done within the generation function and it returned a value depending on the inputs. I'm sure you could do something similar to make sure the user entered exactly 8 digits.

    I haven't tested this, but you might also be able to add some additional Property Generation and Validation Rules to this Policy as far as excluded characters and such to help make sure only numbers are entered for example.