# Create Global variables on fly

**URL:** <https://forum.katalon.com/t/create-global-variables-on-fly/34552>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [October 11, 2019, 4:01pm UTC](https://forum.katalon.com/t/create-global-variables-on-fly/34552 "2019-10-11T16:01:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivek.sanganna](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/vivek.sanganna/32/23869_2.png) [@vivek.sanganna](https://forum.katalon.com/u/vivek.sanganna)\
**Post date:** [October 11, 2019, 4:01pm UTC](https://forum.katalon.com/t/create-global-variables-on-fly/34552/1 "2019-10-11T16:01:18Z")

</div>

Hi , I am fairly new to Katalon studio and I am trying to create a runtime username and add it to the request body. Here are the steps which I have tried doing.

- Created a Global variable
- Created a custom method to generate random email id

When I print out the request body I see that the email is not being set to the variable. Any help would be appreciated on this.!

---

<div class="post-metadata">

**Author:** ![Timo\_Kuisma](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@Timo\_Kuisma](https://forum.katalon.com/u/Timo_Kuisma)\
**Post date:** [October 11, 2019, 4:07pm UTC](https://forum.katalon.com/t/create-global-variables-on-fly/34552/2 "2019-10-11T16:07:51Z")

</div>

hello,

```
	@Keyword
	void addGlobalVariable(String name, def value) {
		GroovyShell shell1 = new GroovyShell()
		MetaClass mc = shell1.evaluate("internal.GlobalVariable").metaClass
		String getterName = "get" + name.capitalize()
		mc.'static'."$getterName" = { -> return value }
		mc.'static'."$name" = value
	}
```

---

<div class="post-metadata">

**Author:** ![vivek.sanganna](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/vivek.sanganna/32/23869_2.png) [@vivek.sanganna](https://forum.katalon.com/u/vivek.sanganna)\
**Post date:** [October 14, 2019, 11:30pm UTC](https://forum.katalon.com/t/create-global-variables-on-fly/34552/3 "2019-10-14T23:30:40Z")

</div>

Thank you so much! Could you also advise me , how to reset the Global variable value at runtime.
