This is the second post in a series focused on Data Flow development.
- Part 1: Creating and Deploying a custom Data Flow Item Class Library
- Part 2 : This one
- Part 3 : Passing arguments to Data Flows executed from Workbooks
- Part 4 : Debugging custom Data Flow Item Class Libaries
This post will show you how to create a parameterized Data Flow Item and execute it in a Data Flow. It’s a follow up to Creating and Deploying a custom Data Flow Item Class Library, so we’ll use the class library we created there. The way parameters are used, however, is exactly the same whether we use our own custom library or a built-in library.
Create the Data Flow Item
- In the Solution explorer, right click a node (Folder, Data Store, etc) and add a new Data Flow Item. Call it InfoTraxx Writer.
This will open the Data Flow Item editor and the Data Flow Item explorer. - In the Data Flow Item explorer, navigate to ResourceSets/Local Resource Sets, right click and add a new Resource Set
- Right click the newly created node, and add a New Assembly Reference
- In the editor, click Browse and select the InfoTraxx library. Note that you must have successfully registered the assembly in InVision in order for it to appear in the dialog. If you expand the Resource Set node after confirming the selection, you can see the new InfoTraxx Database API has been added.
- Next, click the Tasks node in the explorer so that the Actions toolbox group (on the right) becomes enabled.
- Click the Actions toolbox group and you’ll see that our InfoTraxx Database API is available to us.
- Expand all the way down to the AddMessages method and drag and drop it onto the task list in the center of the screen.
Configuring the [AddMessage] Task
After completing the steps above, we’ve created a task that can execute the AddMessage function we’ve implemented in our InfoTraxx database API library.
If you double click the [..].AddMessage task in the Tasks list or expand the Tasks node in the DFI explorer and select the AddMessage task node, the Task editor will open. The task editor is used for specifying during which phase the task should execute, the arguments to pass to the (task) function and optionally where the output should go.
- Change the Execution Phase to Phase 1
- In the arguments editor, right click the Value cell and choose “Insert Parameter“.
- In the Name field, type “Message”
- Optionally, in the Caption field, type “Message”. This will be the display name of the parameter in the Data Flow and Workbook argument editors.
When inserting a parameter using the dialog, two things happen.
First, a new global Data Flow Item parameter is created and added to parameters list of the Data Flow Item. You can see all the DFI parameters by clicking the Parameters node in the DFI explorer.
Secondly, the parameter name (@[Message]) is mapped to the (message) argument. This way, when you pass an argument to the Data Flow Item when it’s being executed in a Data Flow, the argument will be passed on the the (AddMessage) function.
Note that you can do this manually by adding the parameter to the DFI parameters list and then typing the parameter name into the the arguments list of the function. It’s just a reference by name, so there’s nothing fancy going on here.
The AddMessage Task configuration should look like the image below, and we’re ready to execute the Data Flow Item.
Executing the Data Flow Item
To execute the Data Flow Item, switch to the Solution Explorer
- Right click a node (folder, Data Store, etc) and select New Data Flow
- In the Data Flow editor, expand (or search) the Data Flow Items node in the Executables toolbox group and locate the InfoTraxx Writer Data Flow Item.
- Drag and drop it onto the Data Flow designer surface.
- Select the Data Flow Item in the designer surface. In the properties editor, enter a value for the Message parameter.
- Execute the Data Flow from the menu. If you have done everything correctly, the execution should succeed, and there should be a new entry in the Message table in the InfoTraxx database.
The next step
In the next post, we’ll execute the Data Flow from a Workbook and specify the message from there, instead of hard coding it in the property editor.