As a Java object, it can be used in Groovy expressions everywhere in the workflow editor, such as in forms, to populate widgets or to control user entries. For more information on working with Groovy, see http://groovy.codehaus.org/Processing+XML.
A Javadoc for the MDMContext class is available in the Eclipse help, under Talend MDM > API Reference.
The mdm_context variable is created automatically both when you design a workflow using the workflow wizard and when you design a workflow from scratch, but you will need to create it yourself for an Entity Action Process.
To add the mdm_context variable manually, do the following:
In the BPM perspective, click in the workflow pool and then, in the lower part of the perspective, click the Data tab under General to open the corresponding view.
Click the Add button.
In the window that opens, define the parameters of the variable as follows:
Data type: Java Object
Class: Click the Browse button, start typing MDMContext in the selection field, click this class to select it once it appears in the list of classes proposed, and then click OK.
Click Finish to validate your changes.
Form designers can build expressions associated with each widget to perform specific actions in the MDM database. This section shows how mdm_context can be used to facilitate this task. The example shows how to populate a widget with its initial value using a getValue method.
Getting initial values for a text field
This example shows how to use the mdm_context.getValue method to obtain the initial values for a text field in a widget.
In your workflow, select the step for which you want to build the expression.
Click the Application tab, and then click Pageflow to open the corresponding view.
Double-click the form name, RequestNewPrice in this case, to open it in the workspace.
If the form does not exist, click the Add button to create it and then drag a Text field widget to the form.
Select the Text field widget and then, in the Data view under the General tab, click in the Initial value field and then click the Edit button.
In the dialog box that opens, select Script from the Expression type list.
Next, enter a name in the Name field, and then enter the expression mdm_context.getValue("Product/Price") in the editor.
This is an expression which populates the text field with the value taken from the XPath entered between double quotes, Product/Price in this case.
The name of the expression is shown in the Initial value field. When a user opens the form, this field will now be populated with the relevant data.