Skip to main content
1-Visitor
July 30, 2018
Solved

How to invoke a service from subscription or from another service?

  • July 30, 2018
  • 9 replies
  • 5771 views

Hi Everyone,

 

I have a data change event which trigger a subscription. In this subscription I would like to invoke a service which will be bound to a widget. I am also thinking that I can do it directly in the service code but I could not do that.

I tried use snippets which just insert "me.myservice" and it does not work and I also tried "thing["mything"].myservice();" but also does not work.

 

Any help on that?

 

Thanks,

Felipe Duarte 

Best answer by vxavier

You can make the Catch return an output in the service. 

 

But think more it has to be the same type of the main output. If it is a string or number it is easy, but if it is an infotable... it becomes hard.

 

If the outputs is nothing, you can make the output a boolean. True for the code execute without errors and false with errors. 

9 replies

5-Regular Member
July 30, 2018

The subscription will run the service internally, in the mashup you have to call it again. 

 

If you run a subscription it will not automatically update a mashup. 

 

Can you explain exactly the flow of your data and services and how do you wanna it do be updated ?

 

The right way to call the service of an external thing is: "Things["mything"].myservice();"

Duartefe1-VisitorAuthor
1-Visitor
July 30, 2018

Hi Vinicius,

 

Let's make it simple. I need to popup a message when I got a error with a service. I want to use the navigation widget to do it. So, in my code I have a try/catch where when it got a error it runs what is inside de catch (I did some test with logger and it works). Then I have a service which will be bound with the navigate bind after the service is invoked. This is the point, I need to invoke the service which will trigger the navigation widget.

The service where I have the try catch is a service which create a infotable from csv.

 

Was I clear enough?

 

Thanks,

Felipe Duarte

5-Regular Member
July 30, 2018

Hi Felipe,

 

You can use Validator Widget.

 

After you call your service in your mushup you pass the output for a validator widget, if the output is equals to the error log message, the validate will fire the event true, that you can bind with the navigate link.

 

Hope it helps,

Vinicius.