4 Replies Latest reply on Jul 13, 2007 9:03 AM by Ronald van Kuijk

    Newbie question...

    Raman Humianiuk Newbie

      Is there any opportunity to get TaskInstance by Token?

      Token token = ...
      final Collection taskInstances = token.getProcessInstance().getTaskMgmtInstance().getUnfinishedTasks(token);
      for (Object taskInstance : taskInstances) {
       if (((TaskInstance) taskInstance).getTask().getTaskNode().getName().equals(token.getNode().getName())) {
       return (TaskInstance)taskInstance;

      Am I right? Are there any limitations with such aproach?

        • 1. Re: Newbie question...
          Ronald van Kuijk Master

          what you seem to want is get a taskinstance by name or am I wrong? And then only the first one.

          • 2. Re: Newbie question...
            Raman Humianiuk Newbie

            As I understand Token (as execution pointer) and TaskInstance (as newly created task in node when pointer has arrived) and found that they have relationship by the node name in which they are located at the moment. But why is the first one only? Any other suggestions? Any other relationships for addressing TaskInstance in conditions that I only know Token?

            And, Ronald, I knew that only your posts will be the first in my topic :)

            • 3. Re: Newbie question...
              Raman Humianiuk Newbie

              Here is my monologue :)

              Really need some advices because I know that opportunities may lead to 'duplication' TaskInstance for the same Token in the same Node. What is the meaning for this case? And how can I identified TaskInstance by Token in this case?

              • 4. Re: Newbie question...
                Ronald van Kuijk Master

                the first one only because you have a 'return' in your java method in a for loop once a taskinstance is encountered in the taskinstances collection

                Aaahhh... ok, there can't be more than one taskInstance with the same name in one token is what you think... ok... could be true.... not sure though.. just tested it and it is possible to have multiple tasks with the same name in the token, so my assumption that you return the first task in the token with a certain name is (by accident) correct ;-)