# Save random value from list

**URL:** <https://community.gatling.io/t/save-random-value-from-list/3277>\
**Category:** Gatling (Open-Source)\
**Created:** [September 19, 2016, 10:07am UTC](https://community.gatling.io/t/save-random-value-from-list/3277 "2016-09-19T10:07:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aiste\_Simkute](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@Aiste\_Simkute](https://community.gatling.io/u/Aiste_Simkute)\
**Post date:** [September 19, 2016, 10:07am UTC](https://community.gatling.io/t/save-random-value-from-list/3277/1 "2016-09-19T10:07:17Z")

</div>

Hello,

I have values list and I need just one random value and use it several times.

For example,

val scn = scenario(“SimpleScen”)  
.exec(http(“users”)  
.get("/users")  
.check(jsonPath("$[\*].id").findAll.saveAs(“allUsers”)))

.exec(http(“projects”)  
.get("/projects?&userId=" + “${userID}”)  
)

.exec(http(“payments”)  
.get("/payments?&userId=" + “${userID}”)  
)

I know that I can get random value “${userID.random()}”, but I need the same value to use both times. How can I save it?

Thanks,

Aiste

---

<div class="post-metadata">

**Author:** ![Aiste\_Simkute](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@Aiste\_Simkute](https://community.gatling.io/u/Aiste_Simkute)\
**Post date:** [September 19, 2016, 12:27pm UTC](https://community.gatling.io/t/save-random-value-from-list/3277/2 "2016-09-19T12:27:32Z")

</div>

- Random value can get from “${allUsers.random()}”
