how to fetch/pull/extract data from dashboard widgets of RTC.
One answer
Hello there Krunal,
First thing.
In what language? Javascript or Java?
Second thing.
Is this a built in Widget or a third party one?
Greetings
Comments
Depends how you can access the Widget.
1:
If its a built in Widget you have to access it externally.
Maybe its easier to just read the HTML-Label if you need that value.
But I do NOT suggest this!
2:
If it's your own code you just have to read the distinct value.
Then it depends on how this value is set. Maybe Array.length.
I really don't get what you want to achieve since it's not that easy to access data inside a Widget. The other point is, that this value is only present when this particular widget is loaded. So it's kind of dangerous to build logic on that value.
1 vote
Hi Jonas,
Hy Krunal,
Ok I might have an Idea how you could achieve that use case.
But remember, I'm just useful for Javascript questions since I haven't that much experience on the client side Java API.
My steps to achieve that would be:
1: Build a query which represents the data I need.
2: Get the query data over XHR
-Now you know exactly how much defects are in your system.
Where do you store the information about the "Kilo Lines of Code"?
If it's a value inside the defect it's also easy to calculate this because through the query you'll also have the different Workitems (defects in that case)
3: Display the whole thing in HTML the way you want.
1: How to detect how many Defects are in the System?
I'd suggest you to build this logic with a query.
2: Then load the query into your Widget with XHR.
Maybe you do wonder how could I access a query and its data?
This will do the trick
https://myServer.xy/application(This case ccm)/oslc/queries/queryID
https://myServer.xy/ccm/oslc/queries/_te5rttgzuhjit45
1 vote
Logic
require -> "dojo/request/xhr"
require -> "dojo/Deferred"
getRequest: function(url, returnType, preventCache){
returnType = (returnType) ? returnType : "text";
preventCache = (preventCache) ? preventCache : false;
//Header should be based on the return type
var xhrHeader = {"accept":"application/xml"};
var deferred = new Deferred();
xhr(url, {
handleAs: returnType,
method: "GET",
headers: xhrHeader,
preventCache: preventCache,
sync: false
}).then(function(response){
deferred.resolve(response);
}, function(error){
deferred.reject(error);
});
return deferred;
},
/*Usage*/
var queryToLoad = "https://myServer.xy/ccm/oslc/queries/_te5rttgzuhjit45"
getRequest(queryToLoad, "json", true).then(function(innerResponse){
//Handle success
}, function(err){
//Handle error
});
Thanks Jonas,
Comments
Krunal Gaoli
Mar 24 '17, 12:51 a.m.Thanks Jonas,