Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi Team,
Suppose I have a grid widget with live data populating on it with some service.
What I want if any new row gets added to above data then my grid data gets refreshed immediately (i.e. the service populating data gets called on addition of any new row event) without using auto-refresh. Also don't want to reload the entire page.
Please provide some logic so that this functionality can be achieved.
Thanks in advance.
Solved! Go to Solution.
I've done this a couple of ways. One, is to create a numeric Global Session Parameter and use the Resources["CurrentSessionInfo"].SetGlobalSessionNumberValue(params) snippet to set it to a random value every time you add rows to your infotable. In your mashup, just grab the 'changed' event of that session param and tie it to the service that retrieves your data.
Another way, is if the infotable is a property on a Thing (or you can use the same random method as above), you can select the 'Automatically update values when able' checkbox when you use the GetProperties service in a mashup. Instead of having to pull the property values every time, it will automatically push them to your mashup without having to do a refresh.
Hope that helps!
I've done this a couple of ways. One, is to create a numeric Global Session Parameter and use the Resources["CurrentSessionInfo"].SetGlobalSessionNumberValue(params) snippet to set it to a random value every time you add rows to your infotable. In your mashup, just grab the 'changed' event of that session param and tie it to the service that retrieves your data.
Another way, is if the infotable is a property on a Thing (or you can use the same random method as above), you can select the 'Automatically update values when able' checkbox when you use the GetProperties service in a mashup. Instead of having to pull the property values every time, it will automatically push them to your mashup without having to do a refresh.
Hope that helps!
Could you please let me know how to set Global session parameters in ThingWorx.
Also if you can share the logic of method1 then it would be great.
@ranjank ,
To create a session variable, navigate to the GlobalSessionProperties ThingShape and create a property in there.
Then in your service where you're adding rows to your infotable/stream/datatable, just add this code right after you add the row:
var params = {
name: "myNewSessionProperty" /* STRING */,
value: Math.random() /* NUMBER */
};
// no return
Resources["CurrentSessionInfo"].SetGlobalSessionNumberValue(params);
In your mashup builder, click on Session and find the myNewSessionPropertyChanged event, and tie that to the service that returns your infotable.
Thank you for your response.
Actually one more thing to add, in my use-case all the runtime things of assets is having that infotable property which gets populated with some system like Kepware or anything else then should I write subscription (inherited by all asset things) on datachange event of that infotable property and then in subscription provide above session code.
I don't think I can use second method(GetProperties) as the infotable property is not directly mapped to mashup instead it is being consumed in some custom service which populates data over grid.
Please advise.
@ranjank ,
Yes, you could do it that way.
The second method could work as well. If you have the GetProperties service in your mashup, you'll still have access to the ServiceInvokeCompleted event that should trigger on any property update on the Thing I believe. So you don't necessarily need to use the values from GetProperties, but you could use that event to run your custom service whenever the property values change. I think the downside to that is that it will run on any property update, which, depending on your ingestion rate may be too much.
Hi @ranjank.
If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon