How to check whether users have entered a unique value, e.g. Study ID code

From Lifeguide Wiki
Revision as of 16:26, 21 May 2014 by Judy (talk | contribs)
Jump to navigation Jump to search

To check whether users have entered something unique into a text-entry box, the saveuniquevalue function is used. saveuniquevalue is used in the same way as the savevalue [insert link] function. The only difference is that with saveuniquevalue, if the value entered by an end-user is not unique, the data will be recorded as 'false', and you can use this to stop end-users continuing with the intervention until they have entered a value which is unique.

Example 1 To check a variable entered by an end-user is unique: saveuniquevalue(username, "studyid", page1.interaction1)

Example 2 To direct end-users to a different page if a variable entered by an end-user is not unique: after page1 if (not(saveuniquevalue(username, "studyid", page1.interaction1) goto page_notunique

N.B. If you use saveuniquevalue for a specific interaction, e.g. Study ID number, you must use the saveuniquevalue every time you refer to the Study ID number, in order for the uniqueness to be saved each time. If you use saveuniquevalue the first time and then use savevalue, the uniqueness of the value will not be maintained.

Please click here [1] to view a demo of how the saveuniquevalue can be used. To view the logic file, download this demo and import it to the LifeGuide authoring tool.