2

Hi I am trying to assign value extracted from one sampler to another variable in a beanshell script. I have the below beanshell script.

  vars.put("linkArr",vars.get("${PlanLinksArray_1}"));

the text request in jmeter is showing the below for beanshell sampler

vars.put("linkArr",vars.get("9PacMiSVl6GIQAtco747NQ"));

but the linkArr variable is showing a null value in the debug sampler.

why is that i am getting a null value when I am expecting 9PacMiSVl6GIQAtco747NQ value to be assigned to the linkArr variable. please suggest

beanshell request shown below

debug sampler result for linkArr shown below

mo0206
  • 791
  • 5
  • 20
  • 36

2 Answers2

2

You try to get the value of a variable named 9PacMiSVl6GIQAtco747NQ. As such variable doesn't exist, your vars.get returns null.

This is because

  1. The variable ${} gets resolved and becomes a string value.
  2. The beanshell function is executed and tries to get a variable with the in 1st resolved variable-name.

In general: Within beanshell ${} is almost never needed (except for very specific purposes).

Try this instead:

vars.put("linkArr",vars.get("PlanLinksArray_1"));
ByteNudger
  • 1,545
  • 5
  • 29
  • 37
0

Do this:

vars.put("linkArr",vars.get("PlanLinksArray_1"));

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116