# Scripting does not run

**URL:** <https://forum.inductiveautomation.com/t/scripting-does-not-run/67712>\
**Category:** Ignition\
**Created:** [December 16, 2022, 12:51pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712 "2022-12-16T12:51:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lei\_Qu](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lei\_Qu](https://forum.inductiveautomation.com/u/Lei_Qu)\
**Post date:** [December 16, 2022, 12:51pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/1 "2022-12-16T12:51:56Z")

</div>

Hi,

I am using Ignition 8.1.21.

My application is to use a PLC tag value change to trigger a scripting function to run. However it does not work. Even though I see the tag value is changed by the PLC, but the scripting does not run at all.

Can anyone have the scripting experience share some insights?

Thanks.

Lei

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 16, 2022, 1:05pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/2 "2022-12-16T13:05:06Z")

</div>

Where is the script located?  
Can you share the script? When you do use the \</\> button in the forum editor to properly format the script.

---

<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:** [December 16, 2022, 1:06pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/3 "2022-12-16T13:06:13Z")

</div>

Also, look in your gateway log to see if there are errors reported from when you first set it up (or restart the tag to make such errors show up again).

---

<div class="post-metadata">

**Author:** ![Lei\_Qu](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lei\_Qu](https://forum.inductiveautomation.com/u/Lei_Qu)\
**Post date:** [December 16, 2022, 1:26pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/4 "2022-12-16T13:26:19Z")

</div>

Please review the image below. When a button (bPrintLable\_Raptor\_OP200\_PB) is pressed, I use the Value Changed to call the function DBInsertTest.NewLine(). Can you please review and let me know if anything is wrong here? Thanks.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/2/6260db1c2600691417be0f83175741f4e77b27de.png)

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 16, 2022, 1:33pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/5 "2022-12-16T13:33:09Z")

</div>

So tag scripts are gateway scoped, and the gateway needs to know what project the script is in that you are calling. In the gateway way settings there is this setting:

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

Put your project name in there that holds the script. This is a gateway-wide setting.

You may want to re-think how you are doing that though. DB stuff in a tag script isn't the best.  
Instead, use a Gateway Tag Event Script to do this: Gateway Events -\> Tag Change. Then you won't have to set the scripting project.

---

<div class="post-metadata">

**Author:** ![Lei\_Qu](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lei\_Qu](https://forum.inductiveautomation.com/u/Lei_Qu)\
**Post date:** [December 16, 2022, 2:39pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/6 "2022-12-16T14:39:37Z")

</div>

It works!  
Thanks for the help.

I have another question. when a script line is very long, what is the best way to maintain the readability? Use a line continuation character? I tried "" to break long line but it does not seem work.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 16, 2022, 2:40pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/7 "2022-12-16T14:40:17Z")

</div>

What do you mean? Can you provide an example?

Remember... use the \</\> option when posting code.

---

<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:** [December 16, 2022, 2:46pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/8 "2022-12-16T14:46:22Z")

</div>

If a long, multi-line string constant, use python's triple-quoted constant format. If elements of a list or dictionary, you may break lines after the commas between elements without needing any line continuation mark.

---

<div class="post-metadata">

**Author:** ![Lei\_Qu](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lei\_Qu](https://forum.inductiveautomation.com/u/Lei_Qu)\
**Post date:** [December 16, 2022, 6:23pm UTC](https://forum.inductiveautomation.com/t/scripting-does-not-run/67712/9 "2022-12-16T18:23:17Z")

</div>

Thanks, guys. Great help.
