# Define global variable in homey script to be used in flow

**URL:** <https://community.homey.app/t/define-global-variable-in-homey-script-to-be-used-in-flow/54402>\
**Category:** Questions & Help\
**Created:** [November 6, 2021, 6:11pm UTC](https://community.homey.app/t/define-global-variable-in-homey-script-to-be-used-in-flow/54402 "2021-11-06T18:11:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlend\_oyen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erlend_oyen/32/18133_2.png) [@erlend\_oyen](https://community.homey.app/u/erlend_oyen)\
**Post date:** [November 6, 2021, 6:11pm UTC](https://community.homey.app/t/define-global-variable-in-homey-script-to-be-used-in-flow/54402/1 "2021-11-06T18:11:04Z")

</div>

Hi

i have the data i want to use in a variable in homey script defined in:

var data = body2.value  
console.log(data)

output:  
-4.418066024780273

i have tried using:

global.set(‘myHomeyScriptVariable’, ‘data’);

no errors, but it does not look like the variable is getting created or set.

the plan is to use the variable in a flow to do the rest of the work.

any suggestion’s?

thanks!

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [November 6, 2021, 6:23pm UTC](https://community.homey.app/t/define-global-variable-in-homey-script-to-be-used-in-flow/54402/2 "2021-11-06T18:23:44Z")

</div>

In flows we use logic and call the variables tags  
See the examples

> <https://github.com/athombv/com.athom.homeyscript/blob/master/examples/tag.js>

---

<div class="post-metadata">

**Author:** ![erlend\_oyen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erlend_oyen/32/18133_2.png) [@erlend\_oyen](https://community.homey.app/u/erlend_oyen)\
**Post date:** [November 6, 2021, 6:27pm UTC](https://community.homey.app/t/define-global-variable-in-homey-script-to-be-used-in-flow/54402/3 "2021-11-06T18:27:39Z")

</div>

wow that was fast!

i had mixed variables and tags, worked as expected
