# Difficulties with saving random value to a separate variable from Vector

**URL:** https://community.gatling.io/t/difficulties-with-saving-random-value-to-a-separate-variable-from-vector/5454
**Category:** Gatling (Open-Source)
**Created:** [January 22, 2020, 6:33pm UTC](https://community.gatling.io/t/difficulties-with-saving-random-value-to-a-separate-variable-from-vector/5454 "2020-01-22T18:33:12Z")
**Posts on this page:** 3
**Page:** 1

<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: [January 22, 2020, 6:33pm UTC](https://community.gatling.io/t/difficulties-with-saving-random-value-to-a-separate-variable-from-vector/5454/1 "2020-01-22T18:33:12Z")

</div>

You’re getting it wrong.  
You don’t need the extra intermediate step, directly use

```auto
  .get("/t/${topicsid.random()}.json")

```

---

<div class="post-metadata">

### Author: ![Jakob\_Dahl](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@Jakob\_Dahl](https://community.gatling.io/u/Jakob_Dahl)
#### Post date: [January 23, 2020, 9:57am UTC](https://community.gatling.io/t/difficulties-with-saving-random-value-to-a-separate-variable-from-vector/5454/2 "2020-01-23T09:57:35Z")

</div>

Thanks for the suggestion, i’m actually using this directly when i need quickly randomize something once, however my interest is focused on the case where i can store that randomized value. For example:

```auto
.exec(http("Random Topic Url1" + "${topicsid.random()}").get("${topicsid.random()}"))
.exec(http("Random Topic Url2" + "${topicsid.random()}").get("${topicsid.random()}"))

```

I’m having here four different randomized values, whereas i’d like to get the same random value for name and request simultaneously. Or to use it as referer header of next requests. Is this possible?

---

<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: [January 23, 2020, 10:04am UTC](https://community.gatling.io/t/difficulties-with-saving-random-value-to-a-separate-variable-from-vector/5454/3 "2020-01-23T10:04:17Z")

</div>

As explained in the documentation, you can’t use Gatling in your own functions.  
Picking a random entry in your functions is something you’ll have code yourself.  
Please check the Session API in our documentation.
