cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use if else conditions in dynamic property expansion

SOLVED
Highlighted
Occasional Contributor

Is it possible to use if else conditions in dynamic property expansion

Hi,

 

I am trying to send a dynamic mock response using dynamic property expansion. I am able to use a ternary operator to set dynamic value. But I want to see if else conditions can be used or not? Below is my sample code which I am trying.

 

Code working with the ternary operator

${=(result.equals("success")?"success":"error")}

 

Code not working with an if-else condition:

${=if(result.equals("success")){"success"}else{"error"}}

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Is it possible to use if else conditions in dynamic property expansion

The problem is that you can't use braces when writing inline scripts. It's a limitation of SoapUI - a significant one since Groovy uses braces often.

 

But this should work...

 

 

${= if(result.equals("success")) "success" else "error" }

 

2 REPLIES 2
Contributor

Re: Is it possible to use if else conditions in dynamic property expansion

You can't use IF Else that way. 

 

Community Hero

Re: Is it possible to use if else conditions in dynamic property expansion

The problem is that you can't use braces when writing inline scripts. It's a limitation of SoapUI - a significant one since Groovy uses braces often.

 

But this should work...

 

 

${= if(result.equals("success")) "success" else "error" }

 

New Here?
Join us and watch the welcome video: