Support Center Support Center Home

GenerateData

GenerateData is an advanced scripting action designed to create dynamic ‘items’ to use elsewhere in a script.

There are 4 types of GenerateData configuration which you can use within your script. When you add the action to your script, select the type you want to add:

  • Email
  • Number
  • Data
  • String
  • Password

Email

If you need to create unique email addresses so as not to always use the same one and therefore be rejected by the target website’s validation, you can create a ‘consistently unique’ email format. This means you can easily search for, identify and delete accounts registered from User Journeys using the defined format. Part of the email addresses used is always consistent (i.e. always starts with “test”), and part is randomised so every address is unique.

  1. Enter a Name. This will create a Script Variable to recall elsewhere in your script using this name.
  2. Enter this into the Format: rapidtest+%s@example.com
  3. Enter this in the Parts attribute: %random_string%
GenerateItem Email address

The “%s” in the Format will be replaced by “%random_string%” Parts. This will produce an email address such as:

  • rapidtest+1Bstt8Ay@example.com
  • rapidtest+gaS47F10@example.com
  • rapidtest+Ru4S4gM3@example.com

If you wish to increase the randomisation you can add the random string twice. Just add an extra “%s” to the Format and then a second “%random_string%” to the Parts (comma separated).

  • Format: test+%s%s@example.com
  • Parts: %random_string%,%random_string%

Number

This setting generates randomised numbers into formats that can include pre-defined alphabetical characters.

The Format option is free text so you can enter anything into it. Any hash symbols (#) will be replaced with a random number between 0 and 9. Examples:

  • 0161 ### #### – 0161 723 1185 (landline phone number with pre-defined area code)
  • +447######### – +447882847294 (mobile number with pre-defined country code)
  • PR##-##-A# – PR51-08-A1 (random product/SKU code to a pre-defined format)
  • AW## #DB – AW13 9DB (random post code for a specific area)

This example will generate a random UK mobile number into the variable name.

Date

Format

The format dictates how the date will be generated and can be used for producing whole or part dates and times. Format options can be found here. If you wish to enter a character and not have it interpreted into its corresponding format option, then it must be escaped with a backward slash (\).

  • Y-m-d – this would produce a date such as “2022-08-27”
  • H:i:s – this would produce a time such as “10:55:25”
  • Y-m-d H:i:s \(\B\S\T\) – this would produce a full timestamp including a set timezone in brackets “2022-10-05 09:59:15 (BST)” (note the backward slashes to escape the brackets and timezone characters)
  • Y – this will simply produce the year such as “2022”

If you require multiple date parts to use separately then you will need to use multiple Date actions, one per date part.

Transform

This option can be used to dynamically change the date and time returned using a plain text expression. If no Transform option is given then the date and time will default to the server’s current timestamp in UTC.

Some examples of plain text transform expressions:

  • “+7 days” – this will produce a date that is +7 days ahead of the server’s current date when the test runs
  • “next Monday” – this will produce the date of the next Monday
  • “last year” – this will produce the current date, minus one year
  • “+1 week 2 days 4 hours 2 seconds” – this will produce the date to the provided Format but exactly 1 week, 2 days, 4 hours and 2 seconds in the future

Note: the date produced will always be relative to the server’s current date and time in UTC when it runs a test of your script.

This example generates a “Y-m-d” formatted date 7 days in the future.

String

This type generates randomised strings. Whilst very similar to the Password GenerateItem type, this type will only use alphabetical characters. Its intended use was for generating random names or addresses.

The Transform option allows you to specify the case of the string. Available options are: ‘UpperFirst’, ‘UpperAll’, ‘LowerAll’.

Password

This type simply generates random passwords and doesn’t have any additional options as the others do.

Whilst similar to the random string type, this type differs because it will randomly upper and lowercase the characters, includes numbers and adds two special characters.

The two special characters will be selected randomly from this list: ! ? [ ] { } * £ @

Use in a Journey

You can recall the value you have created in other actions within your script. You can identify it by writing $ScriptVariable.name. For a more in depth guide about recalling items later in your script, see script variables.

Was this article helpful?

Related Articles