How to invoke a service from subscription or from another service?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How to invoke a service from subscription or from another service?
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
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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();"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Vinicius,
It could help but I need to understand better what do mean by output error message? Comes from mashup log or Monitor?
Could you please detail a little bit more this?
Thanks,
Felipe Duarte
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Vinicius,
It is always for the most difficulty way because my main output is Infotable.
The expression can be a test for a property?
Example:
If(myproperty==true){
(???)
} else {
(???)
}
How this code expression should be?
Thanks a lot for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
you could change the datashape that your service returns. so instead of having it return just an infotable you have a shape that contains an infotable and an error code.
i.e.
myDataShape
{
myInfotable, //infotable custom datashape
errorFlag // boolean
}
You could then tie the 'errorFlag' to the validator widget, which in turn could be used to initiate the navigation. You just need a little more care when setting the bindings in the mashup in the composer
K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi K,
Thanks for you reply.
For sure this suggestion about use "errorFlag" is good. I did not know that but since I could make it using a property I will let it as is. But when it become to be more a enterprise system maybe this I will put this idea in place.
Best Regards,
Felipe Duarte
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Vinicius,
First of all, it works :)
So, I use the catch return to change a Boolean property to true. Then I used this property to bind in validator widget and use the property as input and expression. Bound all needed to the validator and navigate widget and got the expected result which was a popup window message.
Thanks a lot for your help and suggestion!
Best regards,
Felipe Duarte
