# Variable value declared in script file

**URL:** <https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [July 28, 2025, 3:45pm UTC](https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013 "2025-07-28T15:45:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [July 28, 2025, 3:45pm UTC](https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013/1 "2025-07-28T15:45:55Z")

</div>

Hi Everyone,

I need help with what I am trying to do.  
here is my setup-

- I have a database table storing config\_key and value.
- I read the table data into a memory tag.
- I have a function written in Ignition which given me tag value for a config\_key.
- I use this function to assign to the variables declared in "GlobalVariables" script file in Project Library as follows-  
Test = Utilities.configurationVariables.getConfigurationValues(["Test"])
- I use the Variables declared in "GlobalVariables" script file throughout the project as follows-  
GlobalVariables.Test
- My assumption was that if I change the value in the database (through a screen) which also writes to the tag, then GlobalVariables.Test will receive the latest value wherever it is being called from as at the time of evaluation the right hand side function will be called and update the variable value and return the latest value.  
But that is not happening. It retains the old value until I make some edits (Like entering a new line) in the GlobalVariables script file.

My goal was to

- Not hit the database for getting config value every time
- Have one place to store all the global variables (global in the sense that they are used throughout the project). Hence GlobalVariables script file.

How can I make the variables fetch the latest value once the config value is changed?  
I'd appreciate help in this matter.

Thanks & regards,  
Ajay Kumar Gupta

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 28, 2025, 3:54pm UTC](https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013/2 "2025-07-28T15:54:24Z")

</div>

You cannot do this reliably via direct construction of an object in a project library script. The lifecycle of scripts is controlled by Ignition, out of your hands, and any data structure you attempt to set up **will** be wiped out whenever necessary changes are made.

You _can_ use our `system.util.getGlobals` function to access a **persistent** dictionary that is created upon startup of the local JVM (the gateway, the Designer, or the Vision client) and keeps the same values around indefinitely. You **must** not store custom Jython classes in this dictionary - only 'plain' Jython primitives or directly imported Java classes.

> **[system.util.getGlobals | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-util/system-util-getGlobals)**
>
> This method returns a dictionary that provides access to the legacy global namespace.

You **should** store and retrieve from this single dictionary instance atomically using Python's builtin `setdefault` function.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 28, 2025, 4:00pm UTC](https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013/3 "2025-07-28T16:00:04Z")

</div>

> [@Ajay\_Gupta](#):
>
> My assumption

Assumptions are sometimes a problem.

Jython, like python, only executes modules' top level **once** , upon first import. Ignition script library scripts are similar to stdlib modules, and are "auto imported" upon first reference after startup or project restart.

Like python stdlib, assignments made at the outer level of an Ignition library script are **persistent initializations** , effectively constants. Mutable objects are commonly **initialized** empty, to serve as caches for other operations.

No more code will run in that script module unless functions or class methods are defined, and those are called from other Ignition events or transforms.

Jython assignments are not **bindings** --there is no builtin live update mechanism.

As it happens, what you are trying to do is a valuable performance optimization, such that I've created most of what you describe in my free Integration Toolkit module, via its `globalVarMap()` functions.

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [July 28, 2025, 4:02pm UTC](https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013/4 "2025-07-28T16:02:50Z")

</div>

Will this reflect the latest value changes made to the config key?

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [July 28, 2025, 4:03pm UTC](https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013/5 "2025-07-28T16:03:27Z")

</div>

How can I use your integration toolkit?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 28, 2025, 4:06pm UTC](https://forum.inductiveautomation.com/t/variable-value-declared-in-script-file/109013/6 "2025-07-28T16:06:04Z")

</div>

> [@Automation Professionals' Integration Toolkit Module](https://forum.inductiveautomation.com/t/automation-professionals-integration-toolkit-module/74934):
>
> Automation Professionals is pleased to announce the immediately availability of a major upgrade to its free Simulation Aids Integration Toolkit module. The new feature justifying the "major upgrade" language is the implementation of eleven thirty-one new expression functions which use iteration to accomplish complex transforms of datasets and lists, to or from other datasets and lists, applying filtering, ordering, and computed new columns along the way. While there are certain operations that…

[globalVarMap()](https://www.automation-pros.com/toolkit/doc/scripting.html#globalvarmap)
