Generating invite codes, access codes, or unique codes is straightforward using BlockSurvey. Here’s how you can do it:
Steps to Generate Invite Codes
Open your survey/form.
Navigate to Settings -> Assignment & Formulas -> Numeric Expressions.
Click on Add expression to create a new Numeric expression.
Name your expression (e.g., "invite-codes").
Use the
Math.random()
JavaScript function to generate random numbers. This function produces a pseudo-random floating-point number between 0 (inclusive) and 1 (exclusive).
Example: Use the below JavaScript code to generate random 10-digit code:
Math.random().toString().slice(2,12);
6. Click on Validate and Save.
Displaying the Invite Code on the Thank You Screen
In the Thank You screen, click or type "@" and select the expression name "invite-codes" from the list of questions, variables, and expressions shown.
Publish your survey/form. Now, when a submission is made, a random invite code will be shown on the Thank You screen.
Sending the Invite Code via Email
You can also send the invite code to respondents via email after they submit the form/survey:
In your form/survey subscribe to Respondent Notification under Settings -> Notifications -> Email Notifications -> Respondent Notification.
This will enable automatic sending of the invite code to the respondents' email upon form submission.
By following these steps, you can easily generate and distribute unique invite codes to respondents using BlockSurvey.