How to Transfer/Refer Jmeter Variables from one Thread Group to another Thread Group?

In many situations, we encounter in referring the variables from one thread group to another. Even I found myself every time I end up in searching for the solution. Finally, I have decided to write it here, there are many ways to transfer variables, I preferably choose the following method.

1) Set up Thread Groups
2) Add a “BeanShell Assertion” to the sampler where you are extracting the value
3) In the Script area of BeanShell Assertion specify as
${__setProperty(SG_Id2,${SG_Id1})} where SG_Id2 is a variable in which we are storing the value of
SG_Id1 , so that we can refer this value anywhere in the testplan across all the thread groups.
4) Now go to next Thread Group sampler where you want to pass the value and give as
5) Now run the test and check the value passed from one thread group to another thread group

Join the Conversation


  1. Where do we add this Bean shel Assertion after the value is generated or before? Also is there anything more to do as this doesnot work?

    1. It depends when you need the variable after the request for the next sampler or before it gets called (Pre/Post). can you give more details, if it is still not resolved.

Leave a comment

Your email address will not be published. Required fields are marked *