Example: Form support for workflows
![](../use-scripts/example-form-su/example-form-su.png)
Forms can be used to enter content within workflows. The forms are defined in the workflow on the “Form” tab, e.g.:
<CMS_MODULE>
<CMS_INPUT_TEXT name="name">
<LANGINFOS>
<LANGINFO lang="*" label="Your name"/>
</LANGINFOS>
</CMS_INPUT_TEXT>
<CMS_INPUT_COMBOBOX name="fruit">
<ENTRIES>
<ENTRY value="Apples"/>
<ENTRY value="Pears"/>
<ENTRY value="Oranges"/>
<ENTRY value="Grapes"/>
</ENTRIES>
<LANGINFOS>
<LANGINFO lang="*" label="Please select fruit"/>
</LANGINFOS>
</CMS_INPUT_COMBOBOX>
<CMS_INPUT_RADIOBUTTON name="vegetable" gridHeight="2" gridWidth="2">
<ENTRIES>
<ENTRY value="Red cabbage"/>
<ENTRY value="Cucumber"/>
<ENTRY value="Celery"/>
<ENTRY value="Carrots"/>
</ENTRIES>
<LANGINFOS>
<LANGINFO lang="*" label="Please select vegetable"/>
</LANGINFOS>
</CMS_INPUT_RADIOBUTTON>
<CMS_INPUT_TEXT name="lastSelection">
<LANGINFOS>
<LANGINFO lang="*" label="Last selection"/>
</LANGINFOS>
</CMS_INPUT_TEXT>
</CMS_MODULE>
While a workflow is executed, the editor can enter values via the input components (“form” tab in the dialog “Workflow Action”) that have been defined in the form area.
The saved values can be output in the workflow at a later time.
In the example workflow, a script called “guitest” for displaying and storing the values, which have been entered in the forms, is run via the activity.
For information on pop-up dialogs, see Workflows / Messages and Plug-In Development / Message Boxes.
"guitest" script
//!Beanshell
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.agency.OperationAgent;
transition = context.showActionDialog();
data = context.getFormData();
if (transition != null) {
// display selected values
name = data.get(null, "name").get();
fruit = data.get(null, "fruit").get();
vegetable = data.get(null, "vegetable").get();
// save selected values
lastSelection = data.get(null, "lastSelection");
lastSelection.set(name + ", " + fruit + ", " + vegetable);
text = name + " hat " + fruit + " und " + vegetable + " ausgewählt";
requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
requestOperation.setKind(RequestOperation.Kind.INFO);
requestOperation.addOk();
requestOperation.perform(text);
// do transition
context.doTransition(transition);
} else {
requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
requestOperation.setKind(RequestOperation.Kind.INFO);
requestOperation.perform("Sie haben keine Transition ausgewählt.");
}