StojanoVVV
StojanoVVV

Reputation: 43

JMeter - use a variable in another variable

I have to do the following i have a User Defined Variable in Jmeter its value is basicly an XML and i need to assign some variables inside this variables value. I have done the following - <bbc:CorrelationID>${ID}</bbc:CorrelationID> <bbc:MessageID>${ID}</bbc:MessageID> where ID is a Random Variable element but when i run the script it does not place those values inside the variable value.

How do i reference the random variable in the value of another variable?

Side note: It seems to proccess functions if i place them inside the value but not other variables. So another solution will be to figure out a function that will give me a unique String that is the same in both MessageID and CorrelationID(MID and CID must be the same) and be different in every sample. (__Random does not work since the MesgID and CorID will differ from one another).

Upvotes: 2

Views: 3409

Answers (3)

Dmitri T
Dmitri T

Reputation: 168002

You need to wrap this variable into __eval() function, this way JMeter will automatically resolve and evaluate all nested functions and/or variable in the input entity.

More information: Here’s What to Do to Combine Multiple JMeter Variables

Upvotes: 4

StojanoVVV
StojanoVVV

Reputation: 43

Using _eval when using the variable solved the problem for me since i was using it in another function that encodes to base64 this is how the final function looked for me - ${__base64Encode(${__eval(${req})})} - the variable i needed to change in question was "req".

Upvotes: 0

Ori Marko
Ori Marko

Reputation: 58774

__V is exactly what you need

This can be used to evaluate nested variable references

In your case

 ${__V(<bbc:CorrelationID>${ID}</bbc:CorrelationID> <bbc:MessageID>${ID}</bbc:MessageID> )}

ID will have the same vale in both tags.

Upvotes: 1

Related Questions