Adding Random string from a list of possible strings to url parameters?

Hello! How can I add a random string from a list of possible strings to url parameter?
In an Integromat/Make Scenario I use the following code for this:
{{get(shuffle(split("A,B,C,D")); 1)}}
But now I want to do without the Integromat/Make Scenario and set up a query directly.

Hey @paul84,

You can write a global function like this answer in stackoverflow:

function randomString(choices) {
  var index = Math.floor(Math.random() * choices.length);
  return choices[index];
}

and then write in the value field something like: {{ randomString(["A", "B", "C", "D"]) }}

Or you can write the same function as a js query and set the timing to run the query prior to submitting that API query:

var choices = ["A", "B", "C", "D"]
return choices[Math.floor(Math.random() * choices.length)]
1 Like

@jocen Thanks a lot! That worked for me.