It's all about the answers!

Ask a question

How to read workitem list using javascript


Pankaj Sharma (40340) | asked Aug 04 '15, 2:56 p.m.
 I am using RTC 5.0
I have a requirement to create a string by concatenating all the values present in the sub task list (Work item List)

I have used the script as below:
 var selectedValues = workItem.getValue("MyTask");
   var valueNames = '';
   for (var i=0; i < selectedValues.length; i++) {
       valueNames += selectedValues[i].id + ", "
   }

but it is giving me undefined value as output, I think we need to use something else instead of keyword id.
Is there any list of specific attributes to access Name or auto-generated number of workitem present in workitem list.

Accepted answer


permanent link
Donald Nong (14.4k314) | answered Aug 12 '15, 3:15 a.m.
You need to be careful when dealing with JavaScript objects - you just can't assume that the object has an "id" attribute. Do some debugging and see what the object really is. I will show what it looks like in Chrome, and you need to figure out how to read the "id" and "summary" from the object.

Pankaj Sharma selected this answer as the correct answer

Comments
Pankaj Sharma commented Aug 20 '15, 11:08 p.m. | edited Aug 20 '15, 11:08 p.m.

 This worked i used it like selectedValues[i].attributes[1].value.id + ", " and it worked.


Thanks Donald


Pankaj Sharma commented Nov 02 '15, 6:51 p.m.

Hello Donald,

Can you help me how did you debugged this info



Pankaj Sharma commented Nov 03 '15, 3:38 p.m.

Thanks Donald

Your answer


Register or to post your answer.