Configure the Sequential Number Generator Function

This task describes how to configure the sequential number generator function.

Prerequisite: Select the function

  1. In the Data Model Editor, expand a rule.
  2. Click inside the function field (fx) of a response column and select Sequential number generator. If the function row is not displayed, from the View Options menu, select Functions.

    Note: Dynamic data functions are available for lowest level headers only. Complex headers that include lower level headers under them are displayed in italic text (header). To display lower level headers, double-click the column header.

Back to top

Configure the function

In each cell under this function, enter a value in the following format:



  • Offset is an integer. Used as the starting point for generating the output of the sequential number generator.

    Note: To generate a sequence of numbers that differs for each request/response, each cell with this generator function has an internal numerical counter. When the simulation starts, this counter is always set to 0. Each time a generator function is called, the output value is determined based on the offset and counter. After the output is determined, the value of the counter is increased by the value of the increment, or decreased if the increment is a negative number.

  • Increment is a positive or negative integer. Indicates the change to make from one number in the sequence to the next.
  • FormatString defines the format of the output of the sequential number generator.

    The format string includes:

    • a regular text string
    • (optional) one or more special sequences to define the format of the numerical output of the generator

    To determine the output of the number generator, Service Virtualization goes through the format string and constructs an output string using specific rules, explained below.

Back to top

Format special sequences

Special sequences enable you define the format of the numerical output of the function.

You construct special sequences as follows:

  • Each special sequence must start and end with the '#' character.
  • Each special sequence must contain one or more ‘D’ characters. These characters act like a digit wildcard for a number that will be generated by this generator function. The number will always occupy exactly the number of specified digits. If the number does not occupy all digits, zeros are added before it so that it does.


    - If the special sequence is #DDDD#

    - and the number generated by the function is 568

    - the output is 0568.

  • A special sequence may also contain 'd' characters. These characters act as placeholders. If the output of the generator function requires this space, then it will hold a number. If the generated number does not occupy all digits, then the extra spaces are left empty, and not populated with zeros. 'd' characters may only be placed before 'D' characters.


    - If the special sequence is #ddDDD#

    - and the number generated by the function is 9857

    - the output is 9857.

    For the number 125:

    - the sequence #DDDDD# outputs 00125

    - the sequence #ddDDD# outputs 125

    - and the sequence ##dDDDD outputs 0125.

  • You can construct a format string with multiple special sequences.

    Example: You can enter a special sequence to resemble a credit card number format:

    - if the special sequence is #DDDD#-#DDDD#-#DDDD#-#DDDD#

    - and the number generated is 1234567812345678

    - the output is 1234-5678-1234-5678

Service Virtualization defines the output of the generator according to the following additional guidelines:

  • If the number is greater than the maximal number that can be stored within the digits, it is truncated so that it fits within (e.g. if the number was 3456 and the special sequence was #DDD#, the output will be 456).
  • If the number is negative, it is truncated the same way as above. Then an additional offset is applied. The value of this offset is based on the number of digits and is selected so that -1 becomes the biggest number that fits within these digits. For example, if the special sequence was #DDDDD#, -1 becomes 99999. If it was #DD#, -67813 becomes -13 which then becomes 87.
  • For each empty special sequence (when there are two ‘#’ characters next to each other), a single ‘#’ character is inserted into the output string.
  • The numerical output of the generator will be a number that has exactly as many digits as there are 'D' characters in all of the special sequences in the field combined.
  • Any characters that are not part of a special sequence are copied to the output string.

Back to top


Back to top

Data Model Value Description Output
1;1;#ddddd# Begin with 1 and increment by 1, without any preceding zeros 1,2,3,4, …
100;1;#DDDDD# Begin with 100, increment by 1, and use preceding zeros 00100,00101,00102,…
0;10;ITEM#DDDD# Begin with 0, increment in multiples of 10 with preceding zeros and a prefix. ITEM0000,ITEM0010,ITEM0020,…

See also: