These articles describe two functions available for Basic Panels but which also may be used in ordinary projects.
Note: Basic Panels is a Forsta add-on. If you do not have access to this functionality, contact your Forsta account manager for more information.
isUsernameTaken
In Basic Panels, the unique identifier for a panelist is the panelist's username. The IsUsernameTaken function is used in panelist recruitment surveys to check if any previous respondents have selected the same username.
isUsernameTaken(userName)isUsernameTaken returns true if there is already a panelist in the sample with the provided userName (string) in the question with question id "username", false otherwise. Note that the question id must be "username".
It is used in the validation code of the username question (mandatory) in a panel survey:
if(isUsernameTaken(f("username").get())){SetQuestionErrorMessage(LangIDs.en,"User name taken. Please choose another user name."); f("username").set(""); RaiseError();}
The function can also be used in the same way in ordinary projects, to check that the value entered in a question with question id "username" is unique (note that the question must have the question id "username"). If the function is used in ordinary projects, the indexed property should be set on the username question to improve performance.
Note: If you call the function from a survey that is connected to a panel (for example a registration/update profile survey), then the string argument is compared with the username column in the panel, while if the function is called from a survey that is not connected to any panel, then the argument is compared to the username column in the response database of the actual survey.