1. Home
  2. Docs
  3. User Guide
  4. Cases
  5. Dynamic content as input for scripts

Dynamic content as input for scripts

For scripts you can use some JavaScript objects and functions to generate dynamic input. Examples of this are random numbers, random string of a certain length, incremental numbers, and so on.

The way to do that is to use the next format in the input of a variable:
<#=function(parameters)#>

Native Javascript functions

You can use all the native JavaScript functions

Examples:
<#=Math.round(1.6)#>
<#=Math.PI#>

  • mixing custom function and Javasript lib – <#= Math.round(libs.util.randomNumber(0, 1000) * 100)/100 #>
  • using string functions – <#= libs.util.randomText(34).toUpperCase() #> or <#= libs.util.randomText(34).concat(” “, “World!”) #>
  • using string functions directly – <#= “Please visit Microsoft!”.replace(“Microsoft”,”You-get”) #>
  • mathematic formula –  (1*2 + 5) / 7 == 1
  • using array functions – [40, 100, 1, 5, 25, 10].sort(function(a, b){return a – b});

Specific functions

There are some specific functions you can use, for this you use the format:
<#=libs.util.Function(params)#>

Random, date and time functions

  • <#=libs.util.randomNumber(min, max)#> – Random number in a range
  • <#=libs.util.randomNumbers(min, max, len)#> – List of random numbers. In a range and number of items.
  • <#=libs.util.randomInt(min, max)#> – Random integer in a range
  • <#=libs.util.randomInts(min, max, len)#> – List of random integers in a range, number of items.
  • <#=libs.util.randomString(len)#> – String of random characters, including numbers (length)
  • <#=libs.util.randomStringNum(len)#> – String of random numbers (length)
  • <#=libs.util.randomText(len) – String of random text (length) – Only text, no numbers
  • <#=libs.util.randomBirthday ()#> – Random date
  • <#=libs.util.currentDate()#> – Now
  • <#=libs.util.currentTime()#> – Now

Specific Dutch functions

  • <#=libs.util.randomBSN()#> – Random Social number (NL)
  • <#=libs.util.randomLHNR()#> – Random tax number for Dutch companies (concerning salary) (NL)
  • <#=libs.util.randomIBAN()#> – Random bank account number (NL)
  • <#=libs.util.randomVAT()#> – Random VAT number (NL)

Incremental number functions

  •  Increment.number(batchid, start, margin, reset) – incrementing number with steps
    <#=libs.util.Increment.number(“Counter1”, 0, 1, false)#>

“Counter1”, make this a unique as you can.
Reset: true -> starts with start again, false -> continues from previous
The counter is saved in the DB, so it will continue to increment.

  • Increment.numbers(start, margin, len) – create a list of numbers
    <#=libs.util.Increment.numbers(0, 10, 5)#>

From 0 with steps of 10 incrementing, creating a list of 5 items.

Note that this will work for

  • Individual variables
  • Within Complex business objects
  • Via data sheet input

 

 

 

 

 

 

 

 

Was this article helpful to you? Yes No

How can we help?