It's all about the answers!

Ask a question

How to get the state Identifier by state name by program?


Jia Jia Li (8057152192) | asked Aug 14 '12, 2:28 a.m.
Hi, 
If I create query in API to get the status= resolved work item, I need to establish the stateExpression, this need the state identifier. But I only know the state name like resolved.

So how can I get the the state identifier by it name?

One answer



permanent link
Ralph Schoon (63.1k33645) | answered Aug 14 '12, 4:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Jia,

you can either look it up in the process XML, or you can look it up while debugging or you could write a small tool to look at the data. Based on the ProgrammaticWorkItemCreation wiki page example:

        int id = new Integer(idString).intValue();

        IWorkItem workItem = workItemClient.findWorkItemById(id,
                IWorkItem.FULL_PROFILE, null);
       
        Identifier<IState> state=workItem.getState2();
        String stateID = state.getStringIdentifier();
       
        System.out.println("State: " + stateID + ".");


Comments
Ralph Schoon commented Aug 14 '12, 6:08 a.m. | edited Aug 14 '12, 6:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You can also iterate through the available states using the workflow manager.

Your answer


Register or to post 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.