title: Increment user defined variable in JMeter
body: <p>I have a register REST service to be tested for performance. only required parameter mobilenumber has to be changed for every loop/thread request</p>
  
  <p>How can I increment my User defined variable (by increment value stored as another udv) while threading/looping to multiple tests as a part of load test.</p>
  
  <p>Trying to have a jsr 233 pre-processor for all successful register requests</p>
  
  <p>I don't want to use csv as I have only one parameter to be changed</p>
  
  <p>I am reading about var.get() and vars.put() functions which can be used but not getting thorugh it correctly.</p>
  
  <hr>
  
  <p>Trying the following code - the log in shown below the code</p>
  
  <pre><code>log.info("Before execution")
  log.info("${mobileNumber}") // my udv mobileNumber
  log.info("${increment}") // my udv increment value
  
  inc = ${increment}
  
  long number = Long.parseLong(vars.get("mobileNumber"))
  
  number = number + inc
  
  log.info("Incremented number")
  log.info(String.valueOf(number))
  
  vars.put("mobileNumber", String.valueOf(number))
  
  log.info("After Execution")
  log.info("${mobileNumber}")
  </code></pre>
  
  <p>Log : </p>
  
  <pre><code>2014/11/25 09:25:26 INFO  - jmeter.threads.JMeterThread: Thread started: Dummy services 1-1 
  2014/11/25 09:25:26 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: Before execution 
  2014/11/25 09:25:26 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: 9990000000 
  2014/11/25 09:25:26 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: 1000 
  2014/11/25 09:25:26 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: Incremented number 
  2014/11/25 09:25:26 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: 9990001000 
  2014/11/25 09:25:26 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: After Execution 
  2014/11/25 09:25:26 INFO  - jmeter.protocol.java.sampler.JSR223Sampler: 9990000000 
  2014/11/25 09:25:26 INFO  - jmeter.threads.JMeterThread: Thread finished: Dummy services 1-1 
  </code></pre>
  
  <p>As per log, Increment is successful but the vars.put() is not successful ??</p>