# Unable to Run Script on Button Click

**URL:** <https://forum.inductiveautomation.com/t/unable-to-run-script-on-button-click/57426>\
**Category:** Ignition\
**Tags:** perspective, scripting, ignition81\
**Created:** [March 21, 2022, 7:39pm UTC](https://forum.inductiveautomation.com/t/unable-to-run-script-on-button-click/57426 "2022-03-21T19:39:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaheryar\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shaheryar\_Ahmad](https://forum.inductiveautomation.com/u/Shaheryar_Ahmad)\
**Post date:** [March 21, 2022, 7:39pm UTC](https://forum.inductiveautomation.com/t/unable-to-run-script-on-button-click/57426/1 "2022-03-21T19:39:36Z")

</div>

Kindly Help me in solving this. Always getting this error when I simply runs a script on a button click, for getting a value from a text field and writing it to a memory tag.

**Script:**

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

Error Getting

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

Actually, I want a run a script for getting data from Alarm Journal Table and exporting it to Excel.  
For this I use this script, but unfortunately I am getting the same error.

**Actual Script To be Run:**

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

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 21, 2022, 8:00pm UTC](https://forum.inductiveautomation.com/t/unable-to-run-script-on-button-click/57426/2 "2022-03-21T20:00:24Z")

</div>

Perspective events do not work in the same way that vision scripts do.

Use the property selector to select the desired properties

---

<div class="post-metadata">

**Author:** ![Shaheryar\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shaheryar\_Ahmad](https://forum.inductiveautomation.com/u/Shaheryar_Ahmad)\
**Post date:** [March 21, 2022, 8:04pm UTC](https://forum.inductiveautomation.com/t/unable-to-run-script-on-button-click/57426/3 "2022-03-21T20:04:20Z")

</div>

Thank You So Much Irose for responding.

Can you please guide me a little more, from where I could run this script in perspective.  
TIA

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 21, 2022, 8:15pm UTC](https://forum.inductiveautomation.com/t/unable-to-run-script-on-button-click/57426/4 "2022-03-21T20:15:41Z")

</div>

> [@Shaheryar\_Ahmad](#):
>
> from where I could run this script in perspective.

You can’t run either of these scripts as they are in perspective. They are written with respect to Vision.

Specifically the `event.source.*` is invalid outside of vision.

Also perspective components do not have a `.getComponent()` method.

Use the property selector in the top right side of the event script editor to select the component property that you want.

---

<div class="post-metadata">

**Author:** ![tom.leijen](https://avatars.discourse-cdn.com/v4/letter/t/e495f1/32.png) [@tom.leijen](https://forum.inductiveautomation.com/u/tom.leijen)\
**Post date:** [March 21, 2022, 8:19pm UTC](https://forum.inductiveautomation.com/t/unable-to-run-script-on-button-click/57426/5 "2022-03-21T20:19:43Z")

</div>

You are running the script in the right place, the script is just wrong.

The error message states that the ‘event’ object doesn’t have a ‘source’ attribute.

Using self.view will reference the view the button is located in, from there you can point it to the alarm journal table.  
e.g. e.g. if the alarm journal table is a child object of the view and it’s name is AlarmJournalTable use: self.view.AlarmJournalTable
