It's all about the answers!

Ask a question

How to Sort RQM Category in RPE Template ?


sunil kumar (152) | asked Dec 30 '20, 2:00 a.m.
Hi,.

I have imported testcases into RQM, the created test case id are in random, while generating the report through rpe i m getting the random id in the report. I can able to sort the testcase according to the id and title. But in my case i want to sort according to the category field. I'm not able to do that.
I have created the category filed named "TC No." and given numbers in order. So i want to generate the report in the sequence of "TC No.".  while i have searched in the internet  i got an information that this can be done through Java scripting .

Any one can help me to resolve the issue  by providing the javascript or any other solution to generate the test case in sequence order?

Thanks in Advance..

Regards,
Sunil

Accepted answer


permanent link
Subramanya Prasad Pilar (4.1k14) | answered Dec 30 '20, 5:04 a.m.
edited Jan 03, 8:59 a.m.

 Yes, you cannot sort on category/value (which is child attribute). You can store the testcase data (that you want to print) in an array along with feed/entry/content/testcase/category/value in an array. Perform sort on the array and then print the elements from the array. A sample RPE template will look like this:



Use the following JavaScript Code within $6:
if (term == "TC No.") {
_tcNo = value;
}
if (term == "Module") {
_module += "," + value;
}

Use the following JavaScript Code outside $6: //Store testcase data in array
if ( _tcdata == ""){
   _tcdata = [];
}

var obj = new Object();
obj[ "webId"] = webId;
obj[ "title"] = title;
obj[ "tcNo"] = _tcNo;
obj[ "module"] = _module;

_tcdata.push( obj);

//reset the category values
_tcNo = "";
_module = "";

You can then perform sorting. The sort() method will use the compare function to determine the orders of elements.

After this, you can use Iteration element to print the testcases (from the array) into the Cell.
if ( _tcdata != "")
{
  var obj = _tcdata[_i1];
  obj["webId"]; // similarly print obj[ "title"]; / obj[ "tcNo"]; / obj["module"].replace(/(^\s,)|(,\s*$)/g, ''); in other Cells
}

sunil kumar selected this answer as the correct answer

Comments
sunil kumar commented Jan 01, 4:34 a.m. | edited Jan 01, 4:41 a.m.
Hi,

Thanks for your Response.

I have tried the steps but i got the blank report.

In the Iteration script :

while _i*1 < _tcdata.length;

other than this we need to add anything on the iteration script.


Regards,

Sunil




Subramanya Prasad Pilar commented Jan 01, 5:27 a.m.

_i*1 < _tcdata.length is "Do while condition" for the Iteration element. Please check if the data is stored in the array first. You can refer the sample template here. You should use https://<server>:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<projectAlias>testcase?abbreviate=false as URI for Testcase Feed data source.


sunil kumar commented Jan 01, 10:04 a.m. | edited Jan 01, 10:05 a.m.
Hi,

Thank you subramanya it's really worked for me.

Thanks a lot
.
I do have one more query

i m having another category named modules with values M1,M2

i need to print these module content  to the generating content of the test case.
like

TC.no          Module       Title
TCB1001     M1             Login page
TCB1002     M2             Home Page
TCB1003     M1             Payment page

Is there any way to generate like the above one.



One other answer



permanent link
sunil kumar (152) | answered Jan 03, 2:42 a.m.

Hi,

I have tried the script that you have shared, It was creating duplicate testcases in the report as shown below..

Here 1st Column is Test case Id.

9

Payment page

 

M2

6

Login Page

 

 

6

Login Page

 

M1

9

Payment page

 

 

8

Profile Page

 

 

7

Home page

 

M1

8

Profile Page

 

M2

7

Home page

 

 

7

Home page

TCB10001

 

6

Login Page

TCB10002

 

8

Profile Page

TCB10003

 

9

Payment page

TCB10004

 


Comments
Subramanya Prasad Pilar commented Jan 03, 8:34 a.m.

I have modified the original answer so as not to include duplicate testcases.


sunil kumar commented Jan 04, 1:26 a.m.
Hi,

Thanks For the Response..

I didn't get the Modified script. If you have updated in the same link, i m not able to acces the link as it was expired.

Regards,
Sunil

sunil kumar commented Jan 04, 11:03 a.m.

Hi,

It's was working well and fine as i want .

The issue got resolved.

Thanks for providing the solution.

Regards,
Sunil


Your answer


Register or to post your answer.