DRA 10: set default values for AD fields on user creation

We need to set for our AA  default values on user creation. Like:

company =  Evil corp.

country = Franconia

and some other AD fields.

From microfocus support (#00779210) i got this information:

Instead of editing the desired field on the page, you would use a form load handler. This is done using the form properties button; near the bottom of the page customization. Your handler would run a custom java script. The script needs only one line: draApi-fieldValues['additionalAttributes.draVirtualAttribute'] . In the case AdditionalAttributes.draVirtualAttribute os the exact attribute name linked to a field on the page. You can get the exact attribute name of a feild by using the edit button. This will allow you to see the exact name / format for the attribute. That same test would replace everything after the [' characters in the above example. Lastly the Help Button within the add script section of a form load handler or customer handler on a page contains some usefull details as well.
In general the format of the JS would be something like draApi-fieldValues['compnay'] . If you were using a Virtual attribute you would need to use the additionalAttributes.<Virtual attribute name> . For all other attributes, it would be the name of the attribute displayed when searching for the attribute in the customization of a field. This Java Script would need to be a Form Load handler and not a field based handler. This form load handler would trigger as the web form is accessed by the end user.

Does anyone have already set up this kind of Java Script, and can share an example?

Thank you

  • Following script need to be configured in form load handlers in create user template. Here I am trying to set values for the company, country, and virtual attribute while creating a user. 
    draApi.fieldValues.company = "Microfocus";
    draApi.fieldValues.country = "IN";
    draApi.fieldValues['additionalAttributes.VA-string'] = "VA Attribute";
    Please check if this fits your requirement. 
  • Thanks for your support, but i dont get it to work.

    JavaScript is enabled. I created a "Test User" Property page based on "User - Create Object". After open "Test User" press on "Form Prperties" and add the script under "form load handlers". The script is the same as on your post.

    draApi.fieldValues.company = "Microfocus";
    draApi.fieldValues.country = "IN";
    draApi.fieldValues['additionalAttributes.VA-string'] = "VA Attribute";

    But it does not work. Nothing is set up after user creation. No error message.

  • Verified Answer

    Steps to follow, 

    1. Open properties of customization template.

    2. Create a custom page or in an existing page > add Text or any other control and map attribute say "Company". Repeat the same for country and VA attribute. 

    3. Save the form. 

    4. Launch create > (customization template action) > you should see controls we customized in step 2 should be populated with values as configured in the script. 

    5. Clicking create should save value for these attributes.

    How to attach a screenshot or video to this reply ? Please let me know I will attach relevant screenshots. 

  • Thank you very much. With company an country now it works. Smiley

  • Now i have try the same for "profile",  "homeDirectory" and "homeDrive" but does not work for me.

    Here is the script:

    draApi.fieldValues.profile = "\\server\share\" ;
    draApi.fieldValues.homeDirectory = "\\server\share\" ;
    draApi.fieldValues.homeDrive = "H";

    Result is that on "Profile" page on "Profile Path" and "Home Directory" only  "\servershare" is shown. On "Home Drive" nothing is selected. For "Home  Drive" i have added a extra text field, which was filled with letter "H" but was not written to AD.

    I have a lot more of fields to adapt. Thinking

  • I have tried with this script and its working fine for me. 

    draApi.fieldValues.profile = "\\\\server\\share";
    draApi.fieldValues.homeDirectory = "\\\\server\\share";
    draApi.fieldValues.homeDrive ="H";
    In javascript special characters need to be preceded with \. With respect to homedrive, select control will not reflect the value, but in AD I can see the value got saved. 
  • Thanks for help, i will try this after my vacation.

  • After vacation and some testings i figured out most of the fields (incl. homedrive). But 2 fields make me still problems.

    1. "create in" with the container browser, i will not that the AA can setup a wrong OU. i have tried with draApi.fieldValues.containerOnePointPath = "OU=Stanard,OU=Users,OU=test,DC=LAB,DC=COM" but it does not work

    2. the Optionfield "msNPAllowDialin" can not set to "FALSE" as default

    Do you may have any hints for me?


    it is possible to the value of street depend from the city? So if a AA selects city = Liverpool / street switches to "Penny Lane" and if the AA selects city = London street switches to "Wellesley Rd"? Same for ZIP Code and number?

  • 1. For creatin field you have to pass onepoint path of the container. 

    Eg., draApi.fieldValues.containerOnePointPath = "OnePoint://OU=Users,DC=draTest,DC=lab";

    2. If it's boolean value, if the value is not set, by default false should be set. Do you have this attribute in create or edit page ??

    3. You can configure a custom handler with script in city field to execute when field loses focus. Below script can be used as reference, 

    if(draApi.fieldValues.city == "Liverpool")
        draApi.fieldValues.streetAddress = "Penny Lane";
        draApi.fieldValues.postalCode = "12345";
    else if (draApi.fieldValues.city == "London")
        draApi.fieldValues.streetAddress = "Wellesley Rd"
  • 2. If it's boolean value, if the value is not set, by default false should be set. Do you have this attribute in create or edit page ??

    It is a boolean value (Three-state: true, false,not set) and  i have this on create page.