# doIf syntax

**URL:** <https://community.gatling.io/t/doif-syntax/6008>\
**Category:** Gatling (Open-Source)\
**Created:** [March 9, 2021, 1:45pm UTC](https://community.gatling.io/t/doif-syntax/6008 "2021-03-09T13:45:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@Ankit](https://community.gatling.io/u/Ankit)\
**Post date:** [March 9, 2021, 1:45pm UTC](https://community.gatling.io/t/doif-syntax/6008/1 "2021-03-09T13:45:12Z")

</div>

Can anyone tell me what’s wrong with this syntax please?

 ![Screenshot 2021-03-09 at 2.40.55 PM.png](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/b590f370f6162bc720c3d399cc205cbdcd13a1ce.png)

It says **"Type mistmatch. Required chainbuilder. Found B"**  
Not sure how should i return from the doIf block. Here for example purpose i have put “true” instead of actual boolean condition.

This is the example in Gatling documentation.

doIf(session =\> session(“myKey”).as[String].startsWith(“admin”)) { // executed if the exec(http(“if true”).get("…"))  
}

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [March 9, 2021, 1:52pm UTC](https://community.gatling.io/t/doif-syntax/6008/2 "2021-03-09T13:52:27Z")

</div>

Your code is correct.

Either you’ve messed up with the imports and don’t have

```auto
import io.gatling.core.Predef._
import io.gatling.http.Predef._

```

or you have an old IntelliJ version where the Scala plugin is buggy and the error you have is a false negative.

 ![Screenshot 2021-03-09 at 2.40.55 PM.png](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/1X/b590f370f6162bc720c3d399cc205cbdcd13a1ce.png)

---

<div class="post-metadata">

**Author:** ![Ankit](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@Ankit](https://community.gatling.io/u/Ankit)\
**Post date:** [March 9, 2021, 1:53pm UTC](https://community.gatling.io/t/doif-syntax/6008/3 "2021-03-09T13:53:34Z")

</div>

Gatling version: 3.5.1  
IDE: intellij

---

<div class="post-metadata">

**Author:** ![Ankit](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@Ankit](https://community.gatling.io/u/Ankit)\
**Post date:** [March 9, 2021, 2:00pm UTC](https://community.gatling.io/t/doif-syntax/6008/4 "2021-03-09T14:00:53Z")

</div>

Ah! Messed up with the imports. Corrected, works fine now. Thanks Stephane for such quick response.
