The following can be run in a JSR223 step using either Beanshell or Groovy, and will return an 8 digit random number (actually a string of 8 random numbers between 0 and 9) as both the result and in a property named RAND for later use.
Adapt to suit your needs.
Random rn = new Random();
String a = new String();
for (i=0; i<8; i++) {
a = a + rn.nextInt(10).toString();
}
testExec.setStateValue("RAND", a);
return a;