# Gatling Expression Language doesn't work in functions

**URL:** https://community.gatling.io/t/gatling-expression-language-doesnt-work-in-functions/7231
**Category:** Gatling (Open-Source)
**Created:** [October 19, 2022, 9:03am UTC](https://community.gatling.io/t/gatling-expression-language-doesnt-work-in-functions/7231 "2022-10-19T09:03:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ArosanAn](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@ArosanAn](https://community.gatling.io/u/ArosanAn)
#### Post date: [October 19, 2022, 9:03am UTC](https://community.gatling.io/t/gatling-expression-language-doesnt-work-in-functions/7231/1 "2022-10-19T09:03:16Z")

</div>

Hi, I have a feeder counter like: val counterFeeder: Iterator[Map[String, Int]] = Iterator.continually(Map(“counter” → count.getAndIncrement())).  
I have the following scenarioBuilder

```auto
  val scenarioBuilder: ScenarioBuilder = scenario("Kafkaimport")
    .feed(counterFeeder)
    .exec(
      kafka("import_#{counter}")
        .send(session => {
          val c: String = "import_#{counter}"
          println(c)
          "6:" + String.format("%06d", #{counter})
        }, sessionA => {
          val data: Record = data.template
          data.setCounter(String.format("%06d", "#{counter}"))
          data
        })
      ).exitHereIfFailed

```

In the section kafka(“import\_#{counter}”) I get the value of my feeder counter correctly. But in the session Block e.g. here val c: String = “import\_#{counter}” or String.format(“%06d”, #{counter} there is not the feeder value. If I print it out e.g. herer println(c) ==\> console outpur: “mport\_#{counter}. I have also tried with s”${counter}" but it does not help. Does anyone has an idea, why it does not work and how i get the value from the feeder in mein session block ?

---

<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: [October 19, 2022, 11:20am UTC](https://community.gatling.io/t/gatling-expression-language-doesnt-work-in-functions/7231/2 "2022-10-19T11:20:03Z")

</div>

> data.setCounter(String.format(“%06d”, “#{counter}”))

The [Gatling Expression Language documentation](https://gatling.io/docs/gatling/reference/current/core/session/el/) explicitly states that it doesn’t work in functions in a big yellow warning box.

---

<div class="post-metadata">

### Author: ![ArosanAn](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@ArosanAn](https://community.gatling.io/u/ArosanAn)
#### Post date: [October 19, 2022, 11:30am UTC](https://community.gatling.io/t/gatling-expression-language-doesnt-work-in-functions/7231/3 "2022-10-19T11:30:49Z")

</div>

```auto
val c: String = "import_#{counter}"
println(c)

```

that also does not work

---

<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: [October 19, 2022, 11:59am UTC](https://community.gatling.io/t/gatling-expression-language-doesnt-work-in-functions/7231/4 "2022-10-19T11:59:41Z")

</div>

Indeed, as expected. You have to use the [Session API.](https://gatling.io/docs/gatling/reference/current/core/session/session_api/)
