Skip to main content
Dec 13, 2021 4:24 PM UTC
Question

Call function in a service from different service in a Thing

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

Dec 13, 2021 4:29 PM UTC

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.

Dec 21, 2021 7:32 AM UTC

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.