# runScript and Expression Tags

**URL:** <https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057>\
**Category:** Ignition\
**Created:** [September 15, 2014, 5:30pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057 "2014-09-15T17:30:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![WildeKurt](https://avatars.discourse-cdn.com/v4/letter/w/50afbb/32.png) [@WildeKurt](https://forum.inductiveautomation.com/u/WildeKurt)\
**Post date:** [September 15, 2014, 5:30pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/1 "2014-09-15T17:30:51Z")

</div>

Is it now possible to use runScript to run script in the global script library shared? I would thought it would be but I seem to be having problems getting it to evaluate.

Kurt

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [September 15, 2014, 5:56pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/2 "2014-09-15T17:56:33Z")

</div>

Yes, it is now possible. What problem(s) are you having? Any error message?

This article may help for debugging: [perfectabstractions.com/blog … nt-scripts](http://www.perfectabstractions.com/blog/debugging-and-testing-gateway-event-scripts)

Best,

---

<div class="post-metadata">

**Author:** ![WildeKurt](https://avatars.discourse-cdn.com/v4/letter/w/50afbb/32.png) [@WildeKurt](https://forum.inductiveautomation.com/u/WildeKurt)\
**Post date:** [September 15, 2014, 6:09pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/3 "2014-09-15T18:09:58Z")

</div>

Pretty simple: `runScript('shared.OEE.getFaultBit()')`

Runs fine in the script playground. The script in question returns an integer. All I get for tag diagnostics is

> [@](#):
>
> ExpressionException: Error executing script for runScript() expression: shared.OEE.getFaultBit()

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [September 15, 2014, 6:34pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/4 "2014-09-15T18:34:36Z")

</div>

I see. The error message does not provide enough information to determine what the problem is.

Use the “Try/Except with Logging” method of debugging in the  
[Debugging and Testing Gateway Scripts in Ignition](http://www.perfectabstractions.com/blog/debugging-and-testing-gateway-event-scripts) article to get more information about the problem.

Once the error is logged you can see it in the Console Gateway Configuration webpage.

---

<div class="post-metadata">

**Author:** ![WildeKurt](https://avatars.discourse-cdn.com/v4/letter/w/50afbb/32.png) [@WildeKurt](https://forum.inductiveautomation.com/u/WildeKurt)\
**Post date:** [September 15, 2014, 6:57pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/5 "2014-09-15T18:57:40Z")

</div>

That shed some light on things. The script was using system.tag.read. When calling it from the script playground it was fine but when called from an expression tag you I needed to specify the tag provider, in this case [default] in the tag path.

Kurt

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [September 15, 2014, 7:08pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/6 "2014-09-15T19:08:09Z")

</div>

Yes. Great!

---

<div class="post-metadata">

**Author:** ![papermaker](https://avatars.discourse-cdn.com/v4/letter/p/ea5d25/32.png) [@papermaker](https://forum.inductiveautomation.com/u/papermaker)\
**Post date:** [March 2, 2015, 9:35pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/7 "2015-03-02T21:35:57Z")

</div>

I am struggling a bit with runScript in expression tags. My first issue was that I did not immediately realize that these need to call shared scripts vs project(the documentation still says app._), but this makes some sense to me since it is dealing with the tag database.  
The second issue seems to be that I get an evaluation error if I try to import certain modules (I also moved them to the shared._ space). It seems to be my modules that in turn import additional modules - if I import a module without it’s own imports, It does not seem to be a problem. If there are imports in the imported script, I get an ‘error executing script’ error in tag diagnostics.  
Everything works fine in the script playground.  
Do I have to write “flat” modules for use with runScript ?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [March 2, 2015, 9:57pm UTC](https://forum.inductiveautomation.com/t/runscript-and-expression-tags/9057/8 "2015-03-02T21:57:19Z")

</div>

Hi papermaker,

You just can’t import modules that don’t exist to expression tags. For example you can’t import modules from a “project” package because how would a tag know which project to import a Python module from?

You can import any Python modules you want as long as they exist to tags.
