It's all about the answers!

Ask a question

how to fetch/pull/extract data from dashboard widgets of RTC.

Krunal Gaoli (67666) | asked Mar 16 '17, 6:38 a.m.

I have a widget that contain a list of defect work items and there is a count present on widgets i.e how many defect work items are in the given widgets .I want to know how to pull that  count value from widgets and have some calculus on it.

Anyone can help me on same?

Best Regard

Krunal Gaoli commented Mar 21 '17, 9:19 a.m. | edited Mar 24 '17, 12:51 a.m.

 Thanks Jonas, 

Can you please give it to me in JAVA Script.

I want to show it in the form of Widgets.

Best Regards,

One answer

permanent link
Jonas Studer (207917) | answered Mar 20 '17, 4:37 a.m.

Hello there Krunal,

First thing.
In what language? Javascript or Java?

Second thing.
Is this a built in Widget or a third party one?


Jonas Studer commented Mar 21 '17, 9:48 a.m.

Depends how you can access the Widget.

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!

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.

Krunal Gaoli commented Mar 22 '17, 1:56 a.m.

 Hi Jonas,

I would like to describe you my use case for same.

I want to calculate Defect Density for my Project. we are going to calculate Defect Density using below formula:
 i. DD=Number of Defects/ Kilo Lines of Code.
 ii.DD=Number of Defects/No of test cases. 
I want to show the calculated value in below format
i. If possible in the form of Report. 
ii. In the form of Widgets on dashboard.

Challenges are:
1. How to fetch live number of  defects count data
2. How to show the calculated DD on Dashboard.

Best Regards.

Jonas Studer commented Mar 22 '17, 3:07 a.m.

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.

Jonas Studer commented Mar 22 '17, 3:18 a.m.

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

Jonas Studer commented Mar 22 '17, 3:19 a.m.

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
    }, function(error){
    return deferred;

Jonas Studer commented Mar 22 '17, 3:19 a.m.

var  queryToLoad = "https://myServer.xy/ccm/oslc/queries/_te5rttgzuhjit45"
getRequest(queryToLoad, "json", true).then(function(innerResponse){
    //Handle success
}, function(err){
    //Handle error

Krunal Gaoli commented Mar 22 '17, 4:00 p.m.

 Thanks Jonas,

I am planning to store the value of Kilo Lines of Codes in Customized Work Item.

Regarding number of defects in a system, we can achieve this using query(Defect list ) and Dashboard widgets  (on upper right side its shows number of defects) I want to pull that count (number of defects)
into my WI attribute and have some calculus on it.
I think REST(XHR - Get) will be helpful for me.

If you have any suggestion on it, will be admirable.

Thanks a lot.

showing 5 of 7 show 2 more comments

Your answer

Register or to post your answer.