How to Add Users to Groups in Security

Description

The short summary: use the a5ws_Save_WebUser_values Function, with the possible addition of the a5ws_Validate_WebUser_values Function.

There is no reason to include your own data validation if you are using the a5ws_Save_WebUser_values Function as the function will test all of the validation defined in the Security Settings, including applying a uniqueness test to the user id. In fact, we recommend you do not all any validation to the security fields, as it is possible to add a validation that conflicts with the validation in the Security Settings. If you just want to test the values being submitted, use the a5ws_Validate_WebUser_values Function. It will run all of the validation tests but not save the values. The return pointer variable will have a true value for the .errors parameter, and a false if there are errors. If there are errors, the .error_text parameter will include the error messages defined in the Security Settings. One of the important keys to making the functions work correctly is to always submit a value for the user guid. If this is not supplied as an input value, the functions will consider the submission as a new record as it can't accurately determine if the record exists. Always include the security "guid" field in the fields for the component. This should be a hidden field, but it must be on the component. Input values are values submitted in the "UserValue" or "request" variables as shown in the function help. Output values are returned in the "CurrentForm" or "output" as shown in the function help. As described above, the function returns errors in the output of the "result" variable. However, each output value in the "CurrentForm" will also show a result if there is an error. For example, if the validate function finds an error in the "UserId" field (Using Currentform as the name of the output variable), the following values will be returned:

CurrentForm.has_error = .T.
CurrentForm.Error_Message = error message from Security Settings
CurrentForm.Controls.userid.has_error = .T.
CurrentForm.Controls.userid.error_message = error message from Security Settings specific to this field

This was designed to use in a dialog component which will show the specific error messages by field. A dialog component will show the specific errors as "column heading: error message". This offers some additional flexibility when the functions are used elsewhere as you can also add a value to the submitted values for the control column heading and have it returned as part of the error message. If you are using "output" instead of "CurrentForm",the code would partially look like this for "userid":

dim output.controls.userid.column.Heading as c
output.controls.userid.column.Heading = "Enter Your Login ID"

If the user id has an error such as a duplicate userid, the message would be returned in "output.Controls.userid.error_message" and have a value of "Enter Your Login ID: User ID must be unique".