jmeter

JMeter - Using variables from JDBC request in JSR223 PostProcessor


Based on this thread: Jmeter - Using varible: from JDBC request into another JDBC query under loop

I tried to get variable from DB query and use it.

If I use a parameter value like: ${__V(id_${__intSum(${__jm__Loop Controller__idx},1,)},)} inside a loop controller, it works perfectly fine.

enter image description here

But, if I want to use it in a JSR223 PostProcessor like:

def dbID = '${__V(id_${__intSum(${__jm__Loop Controller__idx},1,)},)}'
log.warn(dbID);

or

def dbID = prop.getObject("id").get(i).get("id")
log.warn(dbID);

my script fails.

What is the equivalent usage of ${__V(id_${__intSum(${__jm__Loop Controller__idx},1,)},)} in a JSR223 PostProcessor?

My script:

enter image description here


Solution

  • Use vars:

     int id = Integer.parseInt(vars.get("__jm__Loop Controller__idx"))+1;
     vars.get("id_"+ id);