Custom method on button component

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??

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)

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??

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?


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: