# Conditional execution of steps

**URL:** <https://community.gatling.io/t/conditional-execution-of-steps/3648>\
**Category:** Gatling (Open-Source)\
**Created:** [March 31, 2017, 11:41am UTC](https://community.gatling.io/t/conditional-execution-of-steps/3648 "2017-03-31T11:41:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mea](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Mea](https://community.gatling.io/u/Mea)\
**Post date:** [March 31, 2017, 11:41am UTC](https://community.gatling.io/t/conditional-execution-of-steps/3648/1 "2017-03-31T11:41:03Z")

</div>

Hello,

I’m trying to use the following setup. In the simulation I have numerous steps and the execution of some of them depend on the successful execution of a previous one. How can I skip a block of steps if one step has failed? For example if get has failed, I want to skip the next 2 steps.

object Agent {

val login = exec(http(“Login agent”)  
.post("/login")  
.body(…)  
.check(jsonPath("$.result…id").ofType[String].saveAs(“agentId”))  
)

val get = exec(http(“Get agent”)  
.post("/get")  
.body(${agentId})  
)  
}

---

<div class="post-metadata">

**Author:** ![Nikolay\_Degkin](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@Nikolay\_Degkin](https://community.gatling.io/u/Nikolay_Degkin)\
**Post date:** [April 6, 2017, 9:53am UTC](https://community.gatling.io/t/conditional-execution-of-steps/3648/2 "2017-04-06T09:53:08Z")

</div>

You can use doIf, for ex. get response code from request 1 and then if it is 200 or your any condition do next block  
[http://gatling.io/docs/2.2/general/scenario/](http://gatling.io/docs/2.2/general/scenario/)
