cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling transitions

kjelllot
Champ in-the-making
Champ in-the-making
Is it possible to disable the transition buttons in the UI like the Save Changes button? Or is it possible to raise an error when a transition is taken and a condition is not met?
In my case a user has a list of values to choose from in his task dialog. He should not be able to complete his task if that value is not equal to a predefined one.

How can I achieve this?

Thanks for any advice
2 REPLIES 2

jmliege
Champ in-the-making
Champ in-the-making
Yes it's possible but you have to override the getAdditionalButtons function in the ManageTaskDialog.



/*
    * (non-Javadoc)
    * @see org.alfresco.web.bean.workflow.ManageTaskDialog#getAdditionalButtons()
    */
   public List<DialogButtonConfig> getAdditionalButtons()
   {
      List<DialogButtonConfig> buttons = null;

         if (this.task != null)
         {
            // get the transitions available from this task and
            // show them in the dialog as additional buttons
            this.transitions = this.task.path.node.transitions;
            boolean isPooledTask = isPooledTask();
           
            if (isPooledTask || this.transitions != null)
            {
                buttons = new ArrayList<DialogButtonConfig>(this.transitions.length + 1);

                if (isPooledTask)
                {
                    if (this.taskNode.getProperties().get(ContentModel.PROP_OWNER) == null)
                    {
                        buttons.add(new DialogButtonConfig("button_take_ownership", null, "take_ownership",
                                "#{DialogManager.bean.takeOwnership}", "false", null));
                    }
                    else
                    {
                        buttons.add(new DialogButtonConfig("button_return_to_pool", null, "return_ownership",
                                "#{DialogManager.bean.returnOwnership}", "false", null));
                    }
                }
                //ADDED A TEST ON OWNERSHIP.
                if (this.isOwnedByCurrentUser() && this.transitions != null)
                {
                   for (WorkflowTransition trans : this.transitions)
                   {
                      buttons.add(new DialogButtonConfig(ID_PREFIX + trans.title, trans.title, null,
                            "#{DialogManager.bean.transition}", "false", null));
                   }
                }
            }
         }
        
         return buttons;
   }

In this case, i've completly took the code of Alfresco, and added a test to check if the current user is owner of the task so that he can't see transitions until he takes the ownership.

kjelllot
Champ in-the-making
Champ in-the-making
Thanks for the fast reply.
This is a solution indeed, but i don't want to make changes to the code as i'am working with config properties (properties defined in my workflow model). I would like to achieve that through scripting inside the process definition but after looking a little closer to JBoss bpm i don't think it's possible (although i'am a newbie in this domain), as i would have to do it in a task-end event and i don't see a posibility to stop a task execution from there.