# How to set variable scope as global

**URL:** <https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299>\
**Category:** Flowable Engine\
**Created:** [December 5, 2017, 12:43pm UTC](https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299 "2017-12-05T12:43:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtmanju](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/mtmanju/32/388_2.png) [@mtmanju](https://forum.flowable.org/u/mtmanju)\
**Post date:** [December 5, 2017, 12:43pm UTC](https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299/1 "2017-12-05T12:43:30Z")

</div>

Hi Flowable Team,

How to set a variable scope as global in Java delegate class ?

Thanks,  
Manjunath

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [December 6, 2017, 3:57pm UTC](https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299/2 "2017-12-06T15:57:54Z")

</div>

Hi,

You can invoke execution.setVariable(“varName”, “test”); to set a process instance level variable.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![mtmanju](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/mtmanju/32/388_2.png) [@mtmanju](https://forum.flowable.org/u/mtmanju)\
**Post date:** [December 7, 2017, 8:35am UTC](https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299/3 "2017-12-07T08:35:53Z")

</div>

Hi @tijs

I am doing the same way, when querying the history it returns the scope of all variables as local.

Could you please let me know is there a way to explicitly to set the global scope ?

Thanks  
Manjunath

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [December 13, 2017, 5:33pm UTC](https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299/4 "2017-12-13T17:33:08Z")

</div>

Can you paste the code you’re using for setting the variables and the call you do for fetching the data through the REST api?

---

<div class="post-metadata">

**Author:** ![mtmanju](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/mtmanju/32/388_2.png) [@mtmanju](https://forum.flowable.org/u/mtmanju)\
**Post date:** [December 14, 2017, 7:11am UTC](https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299/5 "2017-12-14T07:11:17Z")

</div>

HI @joram

Below is the code snippet:

> @Override  
> public void notify(DelegateExecution execution)  
> // TODO: Need to make it to read tenant specific data.  
> execution.setVariable(“var1”, “Hellow”);  
> execution.setVariable(“var2”, “World !”);  
> }

**REST API:**  
[http://localhost:8081/query/historic-process-instances](http://localhost:8081/query/historic-process-instances)

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [December 14, 2017, 4:14pm UTC](https://forum.flowable.org/t/how-to-set-variable-scope-as-global/1299/6 "2017-12-14T16:14:30Z")

</div>

Hi,

Your variables have process instance wide scope, but when you are getting the variables as part of the historic process instance query the returned scope is local, since the scope on a process instance level is set as local. But these are process instance scoped variables, so you’re all good.

Best regards,

Tijs
