a5w_getExtendedUserInfo Function
Syntax
p Result = a5w_getExtendedUserInfo(userid as c [, flagGetCachedValue = .t. [, mode = ""]])
Arguments
- useridCharacter
The User Id to get information for from the Extended User Information Table.
- flagGetCachedValueLogical
Default = .t.. If true and the extended user information was previously retrieved, returns the cached data. If false, retrieves the user information from the database.
- modeCharacter
Default = "". If value is "two", returns the two factor authentication settings stored in the "OtherOptionsJSON" field. If blank (""), returns all extended user information.
Returns
- ResultPointer
Returns a dot variable with the following properties:
- errorLogical
If an error occurs, error will be .t.. Check the value of errorText to learn more about what error occurred. An error will occur if the Extended User Information Table has not been configured or if an error occurred while querying the database.
If no error occurs, this property will be .f..
- errorTextCharacter
If an error occurs, contains information about the error encountered. See "Fixing Common Errors" below for info on how to fix known errors.
- jsonCharacter
A JSON string containing the user info retrieved from the Extended User Information Table. This property will only be available if error is .f..
Description
Reads data from the Extended User Information table.
Discussion
The a5w_getExtendedUserInfo function retrieves information stored for a user in the Extended User Information Table.
Examples
This basic example demonstrates reading data from the extended user information table for user id "[email protected]":
dim p as p p = a5w_getExtendedUserInfo('[email protected]') ?p.error = .f. ?p.json = <<%txt% { "FIRSTNAME" : "John", "LASTNAME" : "Smith", "COMPANY" : "Acme Corp" }
The next example demonstrates how you would get extended user information for the currently logged in user in an AjaxCallback:
function getUserInfo as c (e as p) dim userId as c = a5ws_GetCurrentUser() dim javascript as c = "" dim info as p info = a5w_getExtendedUserInfo(userId) if (info.error == .f.) then ' successfully got data javascript = "alert('"+js_escape(info.json)+"');" else ' an error occurred: javascript = "alert('Error occurred retrieving user data. Error was: "+js_escape(info.errorText)+"');" end if getUserInfo = javascript end function
Fixing Common Errors
A list of common errors and how to fix them are listed below:
Connection string not defined
The connection string was not configured in the Extended User Information Table settings. To fix, go to the Extended User Information Table settings and check to make sure the Connection string property is a valid connection string.
Extended info table not defined
No Extended table was defined. To fix, make sure the Table name property for the Extended User Information Table settings has been set to a table in your database.
UserId field not defined
The User Id field was not configured in the Extended User Information Table settings. Visit the Extended User Information Table settings and set the Userid field name property to the field in the extended user information table that contains the User Id.
Could not open database for Extended UserInfo table.
This error can occur if the connection string defined for connecting to the Extended User Information Table is not correct. Check that the Connection string is correct in the Extended User Information Table configuration.
See Also