Difficulties with saving random value to a separate variable from Vector

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

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

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:

.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?

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.