# Global custom method

**URL:** <https://forum.inductiveautomation.com/t/global-custom-method/40803>\
**Category:** Ignition\
**Created:** [November 19, 2020, 3:47pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803 "2020-11-19T15:47:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![retinder.labana](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@retinder.labana](https://forum.inductiveautomation.com/u/retinder.labana)\
**Post date:** [November 19, 2020, 3:47pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803/1 "2020-11-19T15:47:55Z")

</div>

In perspective I know I can create a custom method at root and call that in any of my components within that view.

Is it possible to call a custom method to multiple views? or would I have to create that method for each view independently

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [November 19, 2020, 4:17pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803/2 "2020-11-19T16:17:46Z")

</div>

Sounds like you just want to create a script module. Is there any particular reason it NEEDS to be attached as a custom method on the root?

---

<div class="post-metadata">

**Author:** ![retinder.labana](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@retinder.labana](https://forum.inductiveautomation.com/u/retinder.labana)\
**Post date:** [November 19, 2020, 4:39pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803/3 "2020-11-19T16:39:49Z")

</div>

It does not have to be attached on root. I just know from previous work that it works on root. But I am not sure how to create a global method that I can use across multiple views within a project

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [November 19, 2020, 6:14pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803/4 "2020-11-19T18:14:50Z")

</div>

In the top left of designer click “Scripting” and then “Project Library”. Right click and select “New Script”, give it a name, for example I will use `myTestScript`. Make a function that does what you want

```auto
def myFunction(your arguments here):
    # your script here

```

Then, im not sure what you want to trigger this script, but you simply do

```auto
import myTestScript

myTestScript.myFunction()

```

to call it.

If its on a root property change it would look like

```auto
import myTestScript

if event.propertyName == 'someProperyName':
    myTestScript.myFunction()

```

---

<div class="post-metadata">

**Author:** ![retinder.labana](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@retinder.labana](https://forum.inductiveautomation.com/u/retinder.labana)\
**Post date:** [November 19, 2020, 6:27pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803/5 "2020-11-19T18:27:18Z")

</div>

Thank you [bkarabinchak.psi] I will give this a try

---

<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:** [November 19, 2020, 6:47pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803/6 "2020-11-19T18:47:28Z")

</div>

A small clarification - you actually most likely _don’t_ want to explicitly import the `myTestScript` - it will be available automatically, and explicitly importing can lead to issues with stale code.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [November 19, 2020, 6:48pm UTC](https://forum.inductiveautomation.com/t/global-custom-method/40803/7 "2020-11-19T18:48:39Z")

</div>

Learn something new everyday
