Skip to main content
1-Visitor
December 13, 2021
Question

Call function in a service from different service in a Thing

  • December 13, 2021
  • 2 replies
  • 1968 views

Hello,

 

I'm creating multiple services in a Thing and i would like to know if it is possible to call function i've created in "Service1" in "Service2" ?

This to not rewrite the function again to have a proper code.

 

Thank you,

Best Regards,

2 replies

22-Sapphire I
December 13, 2021

You can call the service, but not a specific function inside that service, unless you set it up with some input parameters to function like that.

If you have functions you want to 're-use' you should create some 'Toolbox' Thing with those supporting services, or create an extension and add them as a resource.

12-Amethyst
December 21, 2021

Hi,

 

If I understand you correctly:

1. You have a Thing with two services, Service1 and Service2

2. To call Service1 from any other service of the same thing you can use the "me" like that.

 

result = me.Service1();

 

See the example attached.

ashaban_0-1640071934395.pngashaban_1-1640071965101.png

 

 

 

Hope it helps.