It's all about the answers!

Ask a question

Can I get the state group within JavaScript?


Susan Hanson (1.6k2183193) | asked Oct 06 '13, 8:58 p.m.
I know that I can get the STATE of the work item in a validator by using
            var wiState = workItem.getValue(WorkItemAttributes.STATE);


We are trying to do a validator for a different attribute based on StateGroups (basically, a value is okay during "Open" state groups but an error during "In Progress" state groups.

I can do this just by checking every possible state, but it would be easier if I could just get the state group.

Susan

Comments
Millard Ellingsworth commented Oct 08 '13, 9:38 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER

Be certain to make the validated attribute dependent on state changes, too, as a change in the state may need to re-evaluate. There's some discussion of working with state in this other post: https://jazz.net/forum/questions/94496/how-can-i-get-the-old-state-and-new-state-use-javascript-in-calculated-value

One answer



permanent link
Millard Ellingsworth (2.5k12431) | answered Oct 08 '13, 9:31 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER
edited Oct 08 '13, 9:40 p.m.
I don't think you can do this from JavaScript. You would need to query the process specification workflow information in order to retrieve the state groups and see which one the state of the work item is in. Even if you could do this, I'm not sure you'd want to as it could be a long-running operation (dealing with all that XML in JavaScript...) and could make your UI rather sluggish.

JavaScript API

RTC provides a limited JavaScript API that can be used for Attribute Customization. The JavaScript API is very limited and allows only to access attribute data in the context of the work item the attribute customization runs. 

I would bet you could to this with a server-side Java contribution.

Comments
Ralph Schoon commented Oct 09 '13, 1:51 a.m. | edited Oct 09 '13, 1:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Yes, I am pretty sure you can't access that data in JavaScript. For any item you can get the label/name, and the value (which is the UUID or ID for complex data). I am not aware of any more data that can be accessed.
Dependent on the problem, use a participant/advisor or create a java based value provider as described here: https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/

Your answer


Register or to post your answer.