This is the third post in a series focused on Data Flow development.
- Part 1: Creating and Deploying a custom Data Flow Item Class Library
- Part 2 : Executing Data Flow Item Tasks with parameters
- Part 3 : This one
- Part 4 : Debugging custom Data Flow Item Class Libaries
In this post, we’ll continue using your Data Flow from Part 2, but instead of executing it from the designer and hard coding the message we’re writing to the database, we’ll create a Workbook with a text input field for entering the message.
Setting up the Workbook and input
You’ll need to
- Create a Workbook
- Add a page to the Workbook
- Create and add a Text Input Form Element to the page. Call it “Message Input“. (We’ll use the name later for getting the input value)
- Add the Data Flow to the page
- Add a button to the page for starting the Data Flow
Since this post is abount passing arguments to a Data Flow when executing it from a Workbook, I’ll just focus on that part, and not how to create the Workbook and input element for entering the message.
Capturing the user input
The message to write to the database will be entered into the Text Input (Form) element, so we’ll need to pass it as an argument to the Data Flow. There are two ways of doing this.
The first method is to capture the user input and store it in a custom variable while the user enters text in the input element. To do this, you need to subscribe to the SelectionChanged event of the input element, add an ExecuteExpression action and store the current input value in a variable by entering the following statement in the Instructions field :
MyVariable = @Event.Data;
The second method is to use the auto variable for the form element created by the system. The auto variable, @Var[<element name>], always contains the current value of the form element.
You can choose which method to use, they are both equally good in this case.
Configuring the Data Flow arguments
To configure the arguments passed to the Data Flow Items during execution, you need to do the following:
- Select the Data Flow component you added to the Workbook page
- In the properties editor, click Edit ArgumentsThe Data Flow Arguments dialog displays a list of all the activities (Data Flow Item instances) in the Data Flow. By selecting an activity, the parameter list of the activity is displayed. Use this parameter list to assign values to each parameter.
- In the parameter list, find the @[Message] parameter and in the Override Value column, enter @Var[Message Input]. Since we named the input element “Message Input”, we can use the auto variable @Var[Message Input] to get the current value of the input element.
- Configure the button to execute the Data Flow when it’s clicked.
With this setup, the message is passed from the input element to the Message parameter of the Data Flow Item, and then to the AddMessage task within the Data Flow Item which writes it to the database.