# Passing List object as args to a runScript within an expression tag

**URL:** <https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021>\
**Category:** General Discussion\
**Created:** [July 6, 2023, 7:33pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021 "2023-07-06T19:33:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathieurleblanc33](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mathieurleblanc33](https://forum.inductiveautomation.com/u/mathieurleblanc33)\
**Post date:** [July 6, 2023, 7:33pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021/1 "2023-07-06T19:33:29Z")

</div>

Hi All,

I have a script definition that expects 2 arguments which are 2 lists.

- def getGatewayStatus(listDatabaseNames, listDeviceNames):

When using script console, I can pass 2 lists to this definition and it provided a valid dataset return of all Gateway Status tags from System Tags.

I am trying to call this definition using an expression tag of data type dataset.  
The expression keeps coming back with different errors. Using the following:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/f/7f34a1a1cf7b9b12f246822cc7575ffb976e176a.png)

Any suggestion or help on how to construct this runScript statement?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 6, 2023, 7:44pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021/2 "2023-07-06T19:44:14Z")

</div>

What are the errors?

* * *

Tips:

- Post code, not pictures of code. That way we can copy and paste it into our answers. Use the \</\> code formatting button to preserve indentation and apply syntax highlighting.
- For short snippets enclose the code in `` backticks.

---

<div class="post-metadata">

**Author:** ![mathieurleblanc33](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mathieurleblanc33](https://forum.inductiveautomation.com/u/mathieurleblanc33)\
**Post date:** [July 6, 2023, 7:54pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021/3 "2023-07-06T19:54:17Z")

</div>

runScript("project.Gateway.status.getGatewayStatus",0,["databaseName1","databaseName2"],["deviceName1","deviceName2"])

OR  
runScript('project.Gateway.status.getGatewayStatus',0,["databaseName1","databaseName2"],["deviceName1","deviceName2"])

will generate error:  
"Syntax error on token: 'LEFT BRACKET' (line 1, char 55).

---

<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 6, 2023, 7:54pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021/4 "2023-07-06T19:54:43Z")

</div>

You can't construct lists as literals in expressions.  
Depending on where you're executing this you can probably construct your lists as custom properties somewhere and bring them in as references.

---

<div class="post-metadata">

**Author:** ![mathieurleblanc33](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mathieurleblanc33](https://forum.inductiveautomation.com/u/mathieurleblanc33)\
**Post date:** [July 6, 2023, 7:57pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021/5 "2023-07-06T19:57:35Z")

</div>

Instead of bringing back the result into a expression tag of type dataset, and then bind this tag to a table component, sounds like a better option is to run this script behind the scene and assign results directly to the data attribute of a Table component.

---

<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 6, 2023, 8:25pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021/6 "2023-07-06T20:25:38Z")

</div>

> [@paul-griffith](#):
>
> You can't construct lists as literals in expressions.

You can with my latest Simulation Aids. See its `asList()` function.

---

<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 6, 2023, 8:56pm UTC](https://forum.inductiveautomation.com/t/passing-list-object-as-args-to-a-runscript-within-an-expression-tag/76021/7 "2023-07-06T20:56:14Z")

</div>

You could also do something cheesy like make your script function accepts \*args, then call the expression as `runScript("script", 0, "arg1", "arg2", null, "arg3", "arg4")` to separate the pairs of args.

Lots of ways to approach the problem - depends entirely on what you're comfortable with (and will be comfortable maintaining into the future).
