Load Web Security Values


Populate the controls with data from the web security system.

After you register a user into a web security system it is useful to be able to find and edit a record. This guide demonstrates how to use the load web security action. The process is also explained in this video, which is the third video in a series.

Build a Component with a Register and Personal Data Section 

  1. Build the Component described in the Validate Web Security guide and the Save Submitted Data to Table(s).

Add New Security Groups to the Web Security Folder 

  1. From the Web Projects Control Panel click on the 'Web Security' button.

  2. In the Web Security dialog click on the 'Users and Groups' option and click OK

  3. Open the 'Groups' tab and click the 'Add Group' button.

  4. Name the new group 'Customer'.

  5. Click the 'Add Group' button again and name the group 'Admin'. Click 'OK' and 'Close'.

Set the UserRoles Control to be a Radio Button 

  1. Open the UX Component containing the Register and Personal Data Section. Highlight the [UserRoles] Hidden control.

  2. Click the blue 'up' arrow in the Controls page toolbar to move the hidden control inside the 'Register' frame container.

  3. With the [UserRoles] control highlighted view the properties list on the right. Click the [...] button next to the 'Control type' property.

  4. Select the 'RadioButton' control type.

  5. Scroll down to the 'Field Properties' section and set the 'Width' property to be '4.5in'.

  6. Scroll down to the 'RadioButton Properties' section. Click the [...] button next to the 'Choices' property.

  7. Select the 'Variable' radio button option in the dialog that opens. Set the 'Variable name' to be 'UserRoles'.

Add a Load Web Security Values Action to the onDialogInitialize Event 

Once a record in the registered users table is found, the username in the record will be used to find the related security record. In the onDialogInitialize event a variable must be passed to the dialog to find the user in the registered users table. In this example this is a variable named id. A e.rtc variable is set up to populate the radio control for the UserRoles or user groups. The a5ws_GetGroupsDialog() is used to populate the variable. This funcion is specifically designed to be used in the dialog events.

An action script will be used to populate the data from the registered users table. This action uses the variable named 'id' as its primary key source. In the "Populate Dialog with Data from One or More Table(s)" action's properties sheet the 'Capture raw data' property is also checked. In this example the username and registered user data are used to capture to related security record. We need to capture that value in a variable after the record is found. This data will be returned with a variable name "_data" plus the field name, which will be the username. Finally we will add an action to load the security data. With the Load Web Security Values action The prefered value to use is username. You can find the source for the value using a number of options, here we will use the 'local variable' option.

  1. Expand the 'Events' menu and open the 'Server-side' events page. In the 'Server-Side Events' list highlight the 'onDialogInitialize' event.

  2. Add the following lines of code to the event definition.

    dim id as c = "1"
    dim e.rtc.UserRoles as c
    e.rtc.UserRoles = a5ws_getgroupsdialog()
    Here we are adding the 'id' variable and then e.rtc varaible uses this to populate the radio control buttons with the 'UserRoles', or groups, option.
  3. Place the mouse cursor just below the newly entered line of code and click the 'Action Scripting' button.

  4. Highlight the "Populate a Dialog with data from one or more tables" action and click OK.

  5. Name the action 'Load_User' and click OK.

  6. In the action's settings genie, set the 'Primary key source' dropdown to be 'ReadFromVariable'.

  7. Set the 'Variable that contains the primary key' property to be the variable 'id'.

  8. Check the 'Capture raw data' checkbox.

  9. Next to the 'Dot variable name for captured data' property type '_data'. Click OK to close the settings genie.

  10. Place the mouse cursor under the "Populate Dialog from Tables" action and click on the "Action Scripting" button a second time.

  11. From the list of actions, highlight the 'Load Web Security Values' action and click OK.

  12. Give the new action the name 'Load_Security'. Click OK.

  13. In the 'Load Web Security Values' action's settings genie click the dropdown next to the 'Find User By' setting. Select the 'User Name' option.

  14. Click the [...] button next to the 'Find by Value Source' setting.

  15. Select the 'loacl variable' radio button option. Give the local variable the variable name '_data.USERNAME'. Click OK.

  16. Click the 'Load Saved Values' hyperlink at the bottom left-hand corner of the settings genie. This will automatically fill in the 'Assign Variables to Security Variables' section; assuming that the component in the . Click OK.

  17. Resulting event definition.

Run the Component in Working Preview 

  1. Run the component in working preview. Fill in the Personal Data and Register sections of the component.

  2. Click the 'Submit' button.

  3. Open the Design tab and then return to 'Working Preview'. You should see that all of the fields that appear in the registered users table, for the user you defined, will be loaded into the component.

See Also