Bastian Bastian - 3 years ago 204
Groovy Question

vars.get command in groovy verification - jmeter

In documentation mentioned that to see/pass variable content we should use

var2 = vars.get("var1");


I created a script and tried to use this get function and the value is
null
, when I printed the value of the "source" variable I see its value, can someone please explain? (as you can see when I print using get I see
NULL
returned)

Moreover can someone please fully explained (with PIC if I may ask) how to call
var2
in a second sampler, I am facing an issues with variables in groovy and read the DOCs

documantation

enter image description here

enter image description here

Answer Source

vars.get can handle only String and not other objects as Integer,

You need to put the value of Integer using putObject, First groovy:

def old_budget = 137000000
vars.putObject("old_budget", old_budget);

You need to put the value of Integer using getObject, Second groovy:

def old_budget = vars.getObject("old_budget");
log.info(String.valueOf(old_budget));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download