# Custom method on button component

**URL:** <https://forum.inductiveautomation.com/t/custom-method-on-button-component/12371>\
**Category:** Ignition\
**Created:** [November 17, 2016, 10:04am UTC](https://forum.inductiveautomation.com/t/custom-method-on-button-component/12371 "2016-11-17T10:04:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roshanbhosale](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/roshanbhosale/32/4899_2.png) [@roshanbhosale](https://forum.inductiveautomation.com/u/roshanbhosale)\
**Post date:** [November 17, 2016, 10:04am UTC](https://forum.inductiveautomation.com/t/custom-method-on-button-component/12371/1 "2016-11-17T10:04:31Z")

</div>

is it possible to write a custom method on button component which reads value from number of text fields and enters the value one by one into the tags??

---

<div class="post-metadata">

**Author:** ![accyroy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/accyroy/32/3386_2.png) [@accyroy](https://forum.inductiveautomation.com/u/accyroy)\
**Post date:** [November 17, 2016, 10:58am UTC](https://forum.inductiveautomation.com/t/custom-method-on-button-component/12371/2 "2016-11-17T10:58:24Z")

</div>

Yes, in the actionperformed script of the button:

`fieldtext = event.source.parent.getComponent('Text Field').text
fieldtext1 = event.source.parent.getComponent('Text Field 1').text
system.tag.write("Test/Tag1", fieldtext)
system.tag.write("Test/Tag2", fieldtext1)`

---

<div class="post-metadata">

**Author:** ![roshanbhosale](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/roshanbhosale/32/4899_2.png) [@roshanbhosale](https://forum.inductiveautomation.com/u/roshanbhosale)\
**Post date:** [November 17, 2016, 11:47am UTC](https://forum.inductiveautomation.com/t/custom-method-on-button-component/12371/3 "2016-11-17T11:47:20Z")

</div>

thanks for the reply,

but i want to make it as custom method and than call this method in the actionperformed script…is it possible to do so??

the other thing is how to call current time in the script and write it in the tag which is defined as date??

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 17, 2016, 1:37pm UTC](https://forum.inductiveautomation.com/t/custom-method-on-button-component/12371/4 "2016-11-17T13:37:48Z")

</div>

See your other post for the date/time question.

As regards the main topic of this thread, have you looked into using the shared or project script space to store common code?

---

<div class="post-metadata">

**Author:** ![anna](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anna](https://forum.inductiveautomation.com/u/anna)\
**Post date:** [February 23, 2017, 1:00am UTC](https://forum.inductiveautomation.com/t/custom-method-on-button-component/12371/5 "2017-02-23T01:00:49Z")

</div>

roshanbhosale,

If you want to write a custom method just for that component (e.g. button), you can do so in the “Custom methods” section of the component scripting. You can then call that method in event scripts on that component.

If you want that method to be accessible to other components, then you will want to use project or shared script libraries option, as JordanCClark suggested. Check out these videos:  
[inductiveuniversity.com/video/project-scripts](https://inductiveuniversity.com/video/project-scripts)  
[inductiveuniversity.com/video/shared-scripts](https://inductiveuniversity.com/video/shared-scripts)
