# Pass parameter in runScript()

**URL:** <https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529>\
**Category:** Ignition\
**Created:** [December 5, 2012, 3:21am UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529 "2012-12-05T03:21:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 5, 2012, 3:21am UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/1 "2012-12-05T03:21:29Z")

</div>

I have a system script i am calling from a Template. i have a parameter in the Tempalate that contains some path information the script needs. this will be set differently everytime the template is used.  
I can not figure out how to pass the parameter value in the runScript call? if i just hard code it as a string it works fine. But as soon as i use the parameter, even though it has the same value as the string, i get a syntax error.  
Thanks for any help.

---

<div class="post-metadata">

**Author:** ![Michael.Stofan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.stofan/32/3342_2.png) [@Michael.Stofan](https://forum.inductiveautomation.com/u/Michael.Stofan)\
**Post date:** [December 5, 2012, 4:47pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/2 "2012-12-05T16:47:16Z")

</div>

What is the datatype of the parameter that you are passing to the script? It it coming from a UDT?

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 5, 2012, 6:04pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/3 "2012-12-05T18:04:57Z")

</div>

No, not from a UDT ( I dont think).  
it is just a string value entered in a custom property parameter. All i am doing is trying to determine is different sub systems have active alarms by using the system.alert.queryAlertStatus().  
Here is the Module Defiition:  
def SystemActiveAlerts(System,UnAck, Ack ):  
import system  
return system.alert.queryAlertStatus(path=System, activeAndUnacked=UnAck, activeAndAcked=Ack).rowCount

Here is my call, which works, where ‘CA3/PCW/_’ is a path filter:  
runScript("app.alert.SystemActiveAlerts('CA3/PCW/_’, 1, 1)", 5000)

Here is the call that does not work substituting the string above with the same string in a custom property, where Status.System containes CA3/PCW/\*:  
runScript(“app.alert.SystemActiveAlerts({Status.System}, 1, 1)”, 5000)

This results in a Syntax error.  
Thanks,

---

<div class="post-metadata">

**Author:** ![dep05d](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dep05d](https://forum.inductiveautomation.com/u/dep05d)\
**Post date:** [December 5, 2012, 6:16pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/4 "2012-12-05T18:16:17Z")

</div>

I think your call is literally passing in the text “{Status.System}” as the first parameter.

Does this work for you?

```auto
runScript("app.alert.SystemActiveAlerts(" + toStr({Status.System}) + ", 1, 1)", 5000)
```

Dan

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 5, 2012, 8:46pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/5 "2012-12-05T20:46:14Z")

</div>

no luck.  
with it in quotes like that seems like it is literally sending + toStr({Status.System}) +, tried without the quotes and the + and still no joy.  
Thanks,

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [December 5, 2012, 8:58pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/6 "2012-12-05T20:58:59Z")

</div>

In what scope is this expression being run from, an expression tag? Property binding?

Also, what component is the custom property part of? A root container, or a component within the container?

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 5, 2012, 9:20pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/7 "2012-12-05T21:20:57Z")

</div>

Not sure i fully understand the question, but will try.  
This is on a template.  
I have an internal Property defined as an integer called “Acitve”  
I have a Template Parameter defined as a String called “System”  
Active is linked to an Expresion, the expresion equals:  
runScript(“app.alert.SystemActiveAlerts({Status.System}, 1, 1)”, 5000)

System has a string entered into it of:  
CA3/PCW/\*  
Have also tried:  
‘CA3/PCW/\*’

both result in a syntax error.  
If i replace {Status.System}, wtih ‘CA3/PCW/\*’ in the expresion, the expresion then works.

Thanks,

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 5, 2012, 9:25pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/8 "2012-12-05T21:25:19Z")

</div>

Oops forgot, both parameters (System and Active) are defined on the root container.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [December 5, 2012, 9:56pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/9 "2012-12-05T21:56:17Z")

</div>

Ok, thanks for clearing that up, I think I was getting something confused.

Try using concat():

`runScript(concat("app.alert.SystemActiveAlerts('",{Status.System},"', 1, 1)"),5000)
`

The single quotes around your string that your sending to SystemActiveAlerts should fix the syntax error, if not, can you post the full syntax error? Thanks.

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 5, 2012, 10:18pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/10 "2012-12-05T22:18:52Z")

</div>

That did it! 😃  
Now all i have to do, is read up on Concat so I can figure out why.  
Thanks for the help.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [December 5, 2012, 10:49pm UTC](https://forum.inductiveautomation.com/t/pass-parameter-in-runscript/5529/11 "2012-12-05T22:49:56Z")

</div>

Using the concatentation opeators (+) should’ve worked too, it sounds like those single quotes were the missing piece. Glad you got it working.
