Start page
Start page

Start page / Tutorials / Workflows / Messages

Example: Outputting messages in workflows

Within a workflow, messages can be output to the user running it. Messages are output by means of scripts within the workflow. The script displays a dialog to the editor who is responsible for performing the corresponding action within the workflow. Specific information from the context of the workflow can be shown in this dialog.

In this example workflow, an information dialog with the output “Hello $USER” appears before and after a transition is switched:

Once the transition dialog has been activated, another information dialog appears. This contains the output “You have selected transition $TRANSITION. Thank you for the comment $COMMENT”:

"transitionMessage" script

//!Beanshell
import de.espirit.firstspirit.common.gui.*;
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.agency.OperationAgent;
 
userName = context.getGuiHost().getUserService().getUser().getLoginName();
 
text = "Hello " + userName + ". Please select a transition.";
 
requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
           requestOperation.setKind(RequestOperation.Kind.INFO);
           requestOperation.addOk();
           requestOperation.perform(text);
 
context.showActionDialog();
transition = context.getTransitionParameters();
 
if (transition.getTransition() != null) {
 
           text="You have selected transition '" + transition.getTransition() + "'.
A good choice.\nThank you for the comment '" + transition.getComment() + "'";
           requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
           requestOperation.setKind(RequestOperation.Kind.INFO);
           requestOperation.addOk();
           requestOperation.perform(text);
           context.doTransition(transition.getTransition());
} else {
           requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
           requestOperation.setKind(RequestOperation.Kind.INFO);
           requestOperation.perform("You have not selected a transition.");
}

The information which is shown to the editor within the dialogs is retrieved in the script via the workflow context (WorkflowScriptContext), e.g. the transition parameters (see example script):    

context.getTransitionParameters();

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2014-07-16