cancel
Showing results for 
Search instead for 
Did you mean: 

Friendly Error Messages and Workflow Control

tcordova
Champ in-the-making
Champ in-the-making
I have and advanced workflow I'm working on, and at one point I am moving the document to a child folder. I'd like to check for the existence of the folder before attempting to move the doc and do the following if the folder doesn't exist:

1.  Inform the user with a friendly error message
2.  Stop the task without transitioning to another task.

Help?
5 REPLIES 5

nikhil
Champ in-the-making
Champ in-the-making
Can you please share your code.

davidc
Star Contributor
Star Contributor
Within the process definition you can use either a decision node or an exception-handler.  You can't display a friendly message, however you can move to a new part of the workflow e.g. assign new task, send e-mail etc

tcordova
Champ in-the-making
Champ in-the-making
Can you please share your code.

Here's the action in question:


            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  <variable name="dsa_debugMessage" access="write"/>
                  <expression>
                     if (logger.isLoggingEnabled()) logger.log("========== Entering action to set Move Doc to Pending Approval folder in Start State");

                     var dest = bpm_context.childByNamePath("_Pending Approval");
                     if (dest == undefined) {
                        // I want to handle the exception here
                     } else {
                        bpm_package.children[0].move(dest);
                     }
                     dsa_debugMessage = dest;

                     if (logger.isLoggingEnabled()) logger.log("========== Exiting action to set Move Doc to Pending Approval folder in Start State");
                  </expression>
               </script>
            </action>

How do I code an "exception-handler"?

tcordova
Champ in-the-making
Champ in-the-making
Everytime an exception is gnerated, no matter what kind of exception it is, the only message that is displayed back to the user is:

  Please correct the errors below then click Finish.
A system error happened during the operation: Failed to signal transition 'null' from workflow task 'jbpm$230'


Is there no way to at least display the real error, like access denied?

davidc
Star Contributor
Star Contributor
The root cause exception is probably 'access denied' although it's not displayed in the UI.  We need to find a better way to report workflow errors.

However, if you want to control the flow of the process I would use a decision node to test for required state before entering the node that performs the action.  That way, you can explicitly control how to handle issues (e.g. by sending an e-mail, moving to a another task etc).