How to retrieve work Item state using (workItem.getValue( WorkItemAttributes.STATE )) ?
Hello,
I am trying the work item customization in RTC and I want to Retrieve current State of workitem using (workItem.getvalue(WorkItemAttributes.STATE)) and set to other presentation called "Current State Of Task".
i.e.
current State of Task : In process
I have a script Regarding that :
dojo.provide("client.valueProvider.New_A");
dojo.require("dojo.date.stamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("client.valueProvider.New_A", null, {
getValue: function(attribute, workItem, configuration) {
var state = workItem.getValue(WorkItemAttributes.STATE);
if (state) {
switch (state) {
case 'taskworkflow.state.s2': //In Progress
return "In Process" ;
break;
case 'taskworkflow.state.s1': //New
return "New";
}
break;
}
}
return "";
}
});
}) ();
But Its not Work for me.
can anyone have any Idea regarding this ?
|
Accepted answer
The problem is in your "switch" statement. It should be:
-------------
switch (state) {
case 'taskworkflow.state.s2': //In Progress
return "In Process" ;
break;
case 'taskworkflow.state.s1': //New
return "New";
break;
}
--------------------------
Please also read article https://jazz.net/library/article/1360 about how to debug value provider javascript.
Jia jang selected this answer as the correct answer
Comments yes the last break is out of place, not nested correctly.. it should be with the appropriate case..
|
2 other answers
you may want to print out to the console, after you get the state value.. then reuse the returned value for your cases.
|
Jia jang (42●1●11)
| answered Feb 09 '17, 1:16 p.m.
edited Feb 09 '17, 5:11 p.m. by Geoffrey Clemm (30.1k●3●30●35) Lily wang and Dinesh Kumar. I would like to express my gratitude for all that you have done . I am most grateful for your support . Thank you for taking the time to help me , I really do appreciate it. Comments I would appreciate if you would accept one of the correct answers, so that I don't have to. this helps users in seeing the question was answered correctly and they don't have to try to answer. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.