# Expression runscript() not working properly

**URL:** <https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 20, 2023, 5:04pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718 "2023-04-20T17:04:19Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [April 20, 2023, 5:04pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/1 "2023-04-20T17:04:19Z")

</div>

I am trying to run a script in an expression tag. I tried using the runScript() expression function but it is giving me the following tag error:

Error\_ExpressionEval("Error executing script for runScript() expression:Utils.getCardDataset")

Here is my following implementation:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/8/e8d1546da88e1d133634994146f0a4e298134dcb.png)

I am referencing the function just as the documentation suggests that I should but still get the error regardless. I am pretty sure that the issue is not a runtime error in my script as I can run it successfully from the Script Console.

Am I doing something wrong with my function reference here? Or is this a bug?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 20, 2023, 5:06pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/2 "2023-04-20T17:06:42Z")

</div>

This project must be configured as the Gateway Scripting Project in order for tag scripts to reference the script library.

[https://docs.inductiveautomation.com/display/DOC81/Project+Library#ProjectLibrary-GatewayScriptingProject](https://docs.inductiveautomation.com/display/DOC81/Project+Library#ProjectLibrary-GatewayScriptingProject)

---

<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:** [April 20, 2023, 5:08pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/3 "2023-04-20T17:08:11Z")

</div>

> [@Cole\_Townsend](#):
>
> as I can run it successfully from the Script Console.

This is not a good test for anything in gateway scope, as it is a derivative of Vision Client scope.

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [April 20, 2023, 5:20pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/4 "2023-04-20T17:20:54Z")

</div>

Am I missing something here? I do not have the config option for the gateway scripting project under Gateway Settings. Is this a licensing issue? I am running Ignition Edge 8.1.24

---

<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:** [April 20, 2023, 5:31pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/5 "2023-04-20T17:31:45Z")

</div>

Edge doesn't have a 'Gateway Scripting Project' setting, because Edge only allows one project.

Do you have the compute plugin installed/are you in a valid trial? That could be why the script isn't allowed to run.

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [April 20, 2023, 5:41pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/6 "2023-04-20T17:41:22Z")

</div>

No, I do not have the compute plugin installed. I'm guessing that's a full stop on me trying to do this without it.

The actual functionality that I am trying to do is to have opc data populated in this dataset. My initial thought was to return a dataset from a script that populates a python dataset using system.opc.readValues(). From what I can tell, there isn't a great way to pull an array of data from a modbus device without having a separate tag for each register. Am I missing an obvious solution here or is my thinking correct? Trying to read 200 values at once.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 20, 2023, 5:44pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/7 "2023-04-20T17:44:22Z")

</div>

Why can't you just have 200 tags?

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [April 20, 2023, 7:04pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/8 "2023-04-20T19:04:05Z")

</div>

I could, but I was interested in using a dataset as it would be a little more dynamic and less cluttered than having x number of tags. It would also allow me to work with my data a little more intuitively as I can have rows in the dataset representing specific data points. It is seeming like that is what I am going to have to do, but it is a little inconvenient. It would be nice for datasets to be useful for more than just queries or memory sources and actually be able to populate them with data from OPC devices.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 20, 2023, 7:06pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/9 "2023-04-20T19:06:51Z")

</div>

Some of the newer drivers support arrays, but our Modbus driver is pretty old and doesn't.

Dataset isn't a natural mapping for anything that would come from OPC except perhaps a 2-dimensional array, and even then there's no obvious column name or type that can be applied. It only makes sense to build one from scripting, which you may not be able to do since it sounds like you're on an Edge edition that doesn't include scripting access.

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [April 20, 2023, 7:16pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/10 "2023-04-20T19:16:31Z")

</div>

Yeah, the script I have written is the perfect solution to the problem. Just not able to use it atm due to licensing.

Here is the code I used to do it for anyone trying to do something similar:

```auto
def getCardDataset(driveName):
	server = "Ignition OPC UA Server"
	opcPaths = []
	for x in range(200):
		opcPaths.append("[%s]1.HRI%d"%(driveName, 9001+(x * 2))) #the registers I am trying to poll start at 9001
		
	qualifiedValues = system.opc.readValues(server, opcPaths)
	headers = ['Position', 'Load']
	data = []
	for x in range(100):
		qualifiedValue1 = qualifiedValues[x] #This is the values for column 1 of my dataset
		qualifiedValue2 = qualifiedValues[x + 100] #This is column 2
		data.append([qualifiedValue1.getValue(),qualifiedValue2.getValue()])
		
	card = system.dataset.toDataSet(headers, data)
	return card

```

---

<div class="post-metadata">

**Author:** ![Cole\_Townsend](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cole_townsend/32/53149_2.png) [@Cole\_Townsend](https://forum.inductiveautomation.com/u/Cole_Townsend)\
**Post date:** [April 20, 2023, 7:22pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/11 "2023-04-20T19:22:38Z")

</div>

Has scripting ever been considered as an official ValueSource for a tag, similar to how an expression is?

Now that I am thinking about it, I wonder if I can run this function in the runScript() expression function as a one-liner. Does the runScript() function work with lambdas?

---

<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:** [October 24, 2024, 3:34pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/12 "2024-10-24T15:34:12Z")

</div>

Split this topic on October 24, 2024, 3:34pm UTC

A post was split to a new topic: [Issue with expression on tag](https://forum.inductiveautomation.com/t/issue-with-expression-on-tag/97737)

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [June 11, 2025, 11:43am UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/13 "2025-06-11T11:43:21Z")

</div>

If I have Edge Compute how do I define global scripts?

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 11, 2025, 11:52am UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/14 "2025-06-11T11:52:15Z")

</div>

It's done the same way with Edge compute as it is with Standard edition.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [June 11, 2025, 11:55am UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/15 "2025-06-11T11:55:46Z")

</div>

How do I identify the global scripts if there is no "Gateway Scripting Project" setting? This is to use with runScript().

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 11, 2025, 12:02pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/16 "2025-06-11T12:02:33Z")

</div>

Edge only allows a single project, so if the setting isn't there, then it's preset for you.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [June 11, 2025, 12:03pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/17 "2025-06-11T12:03:47Z")

</div>

I do not understand. Preset to what?

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 11, 2025, 12:05pm UTC](https://forum.inductiveautomation.com/t/expression-runscript-not-working-properly/72718/18 "2025-06-11T12:05:02Z")

</div>

Preset to your only edge project. All scripts in your edge project will be accessible as gateway scripts.
