How to get the next state or the current action?
I have written javascript to set the value set of an attribute, and the value set depends on the state of work item, it looks like this:
var state = workItem.getValue(WorkItemAttributes.STATE);
var userOptions = [];
if (state == "1")
{
userOptions.push("Test Team");
}
else
{
userOptions.push("Requirement Manager");
var userOptions = [];
if (state == "1")
{
userOptions.push("Test Team");
}
else
{
userOptions.push("Requirement Manager");
}
When performing an action before saving, the state is still the old value(the original/source state), and the value set is not right, after saving, the attribute give an red asterisk, user needs to modify/choose the attribute's value manually/again.
This behavior is very different from ClearQuest that when performing an action in CQ before saving, the state's value has changed to new/destination one.
One answer
You can only access the current state in JavaScript. You can detect a state change only if your JavaScript has only one dependency which is to the state attribute. You can not access the workflow with JavaScript. There is no API available in JavaScript to access the workflow.
This has been discussed here several times in this forum already. Try searching for Potts.
If that is not sufficient, you need to look at creating a java based extension. http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/ and other posts shows some examples.
Comments
Albert Yao
Dec 28 '12, 3:44 a.m.Anybody could give the way getting the new/next/destination state value will be very appreciated.