title: Update Jmeter variables with beanshell
body: <p>I've encountered a problem when trying to update a Jmeter variable with a beanshell script. I've followed <a href="https://blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell" rel="nofollow noreferrer">this manual</a> and i have seen <a href="https://stackoverflow.com/questions/20150366/beanshell-preprocessor-updates-user-define-variables">this topic</a> and both say the same: </p>
  
  <ol>
  <li>To update a variable use <code>vars.put("variable", "newValue");</code></li>
  <li>The value that you put can only be a String.</li>
  </ol>
  
  <p>Now I want to use this code: </p>
  
  <pre><code>String x = vars.get("counter");
  
  int y = Integer.parseInt(x);
  y = y + 1;
  
  String z = "" + y;
  
  vars.put("counter", z);
  // print(z);
  </code></pre>
  
  <p>My variable counter is a user parameter (tried before as user defined variable) with the value 1. I can see my script is working because the print(z) returns the value 2. Now I also expact that my variable counter is updated in the user parameters so that when I run this again it gives me the value 3. This is not the case: The value is not updated, so everythime I run the script it returns me the value 2.</p>
  
  <p>Anyone who can help me with this? </p>