# RunScript from Expression in UDT Alarm Template

**URL:** <https://forum.inductiveautomation.com/t/runscript-from-expression-in-udt-alarm-template/78487>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 28, 2023, 11:14pm UTC](https://forum.inductiveautomation.com/t/runscript-from-expression-in-udt-alarm-template/78487 "2023-08-28T23:14:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Summer\_L](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Summer\_L](https://forum.inductiveautomation.com/u/Summer_L)\
**Post date:** [August 28, 2023, 11:14pm UTC](https://forum.inductiveautomation.com/t/runscript-from-expression-in-udt-alarm-template/78487/1 "2023-08-28T23:14:19Z")

</div>

I'm trying to shorten the path of a tag through a script, and then calling the script from an expression tag alarm template. The value I get is always null when I pass in {PathToTag}, yet if I pass in the full path in as a string then I get the correct value returned. Any ideas as to what I'm doing wrong? I've already configured the Gateway Scripting for my project.

 ![Screenshot (10)](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/468bab270c28c9088c2333c59817ffe2e5ea143f.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 28, 2023, 11:24pm UTC](https://forum.inductiveautomation.com/t/runscript-from-expression-in-udt-alarm-template/78487/2 "2023-08-28T23:24:50Z")

</div>

You should really be passing in your args via the runScript args, e.g.

```auto
runScript('ShortenTagPath.ShortenPath', 0, {PathToTag})

```

However to pass them in as you are, you need to use:

```auto
runScript('ShortenTagPath.ShortenPath("' + {PathToTag} + '")', 0)

```

Some other things:

- Unless you're just testing, you should really think more about your structure and naming of your script libraries. You shouldn't have a single function in each of your script libraries which is how it appears you're using them. They should hold collections of like-functions for similar purposes. Use IA's `system` library as a good example.
- library and variable names shouldn't use PascalCase. They should use camelCase (or snake\_case)
- You should also _never_ use Python keywords as variables names (e.g. `list` - notice the golden highlighting)
- instead of a for loop and constant reassignments, you can use: `string = '/'.join(lst)`

Here's a link to the Python style guide: [PEP 8 – Style Guide for Python Code | peps.python.org](https://peps.python.org/pep-0008/)  
Note that while snake\_case is preferred for Python, Jython is rooted in Java which uses camelCase so many people prefer this. camelCase is also used throughout the `system` library so using this would make custom functions more consistent across the application.
