Web Form - Set a virtual attribute to a specific string

We have a web form to request a new account.  Whenever a request is submitted I'd like to set a virtual attribute to a specific string like 'NewRequestForm' so we know where the request came from.

Inside of a onGetEffectivePolicy function was where I am trying to do this so far.  It doesn't seem that any attempt to set the VA's value is working though.  I've tried things like $Request.Put and some of the setEffectivePolicyInfo combinations.

This field would not be on the form as it's irrelevant to whoever is filling it out.


Any idea how we can fill in the VA?

Parents
  • Hi Dean,

    On the properties of a form in the web interface, you have the option to include Extended Controls. You can specify a custom control (any control name that doesn't already exist in the product) and any value. Then in your onPreCreate or onPreModify, depending what your form is doing, you can use a try catch to check for the control. If the control is included, then you know it's from that specific form.

    Below is the example from the SDK for getting an In Control.

    $errcount = $Error.count
    trap {continue;}
    $controlValue=$Request.GetInControl("MyControl")
    if ($Error.count -ne $errcount)
    {
       # --- Your code that handles this error goes here ---
    }

  • Hi Nick - Thanks for the speedy reply.  I just tested that and it does appear to work and is a viable answer.  Is there no way to populate the VA behind the scenes in the form submission?

    I only ask because the VA will contain the source of the request.  So if a new user is through out HR system it would be populated with something like SyncService.  If from a form it might be NewUserForm, etc.. This way my scripts I can do if (ProvisioningSource = HRSystem) { Do this }

    With your method I can certainly add some code to make it work if need be.  At the top of the onPreCreate I can just populate a variable with the source through some logic.

  • Hi Dean,

    Below is an example of something I did a while ago with a new user web form specifically for creating a service account to separate it from the default new user form. You'll see how I was able to update the request once it was confirmed that it included the specific control I included. Let me know if that clears things up.

    function onPreCreate($Request)
    {
        if ($Request.Class -eq "user"){
            $errcount = $Error.count
            trap {continue;}
            $controlValue = $Request.GetInControl("newAccountType")
            if ($Error.count -eq $errcount)
            {
               if ($controlValue -eq "serviceAccount"){
                    $username = $Request.Get("newServiceAccountName")
                    $Request.Put("sAMAccountName",$username)
                    $Request.Put("cn",$username)
                    $Request.Put("displayName",$username)
                    $Request.Put("description","Service Account - DO NOT DELETE")
                    $Request.Put("edsaPassword","P@ssw0rd")
                    $Request.Put("edsaAccountIsDisabled",$false)
                    $Request.ChangeParentDN("OU=Service Accounts,DC=ndtest,DC=domain,DC=local")
                }
            }
        }
    }

  • Hi Nick,

    Sorry we were spinning wheels on this and trying to get our professional service team to help iron it out.

    So I am able to get your example working and during the onPreCreate I am able to populate my VA as I need to.  The trouble is that I am trying to have the creation of a user with this VA trigger an approval work flow and it's almost as if the user is created before the onPreCreate so the WF doesn't trigger.


    The WF is simply just on user creation and the VA must equal "NewForm".

    Weirdness I've noticed is that during a onPostGet I can populate the VA in $Request and then immediately get that VA and output the value to a log but when it gets to the onPreCreate that VA is empty.

    I really wish there were more event handlers such as onFormSubmission :|

  • Timing of actions can be tricky.

    With respect to your comment about onFormSubmission...

    This kinda exists with the OnCheckPropertyValues which executes after you either submit the form or hit "Next" in a Wizard.

Reply Children