Skip to main content
All CollectionsFAQs
How to generate unique invite codes or access codes upon completion of the form / survey

How to generate unique invite codes or access codes upon completion of the form / survey

Updated over 3 months ago

Generating invite codes, access codes, or unique codes is straightforward using BlockSurvey. Here’s how you can do it:

Steps to Generate Invite Codes

  1. Open your survey/form.

  2. Navigate to Settings -> Assignment & Formulas -> Numeric Expressions.

  3. Click on Add expression to create a new Numeric expression.

  4. Name your expression (e.g., "invite-codes").

  5. 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

  1. In the Thank You screen, click or type "@" and select the expression name "invite-codes" from the list of questions, variables, and expressions shown.

  2. 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:

  1. In your form/survey subscribe to Respondent Notification under Settings -> Notifications -> Email Notifications -> Respondent Notification.

  2. 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.

Did this answer your question?