By the end of this section you will be able to:
- Create an action that runs a Task Plan
- Use context variables in a model
In this exercise you will create an action that takes a selected file from a list and loads that file into PhixFlow.
The files used in this exercise can be found in the input files, at:
…_ _inputData\BillingReports2
although you will create a process that reads copies of these files from the server. The input directory expression of the file collector in the example is already set up to read files from the correct location on the server.
- Open the model Dashboards and Forms 15. Actions to run tasks – in this model, there is a Stream and File Collector set up to read billing reports; there is also a Stream Billing report list that simply holds a list of file names
- Open the dashboard Manual billing reports load – this dashboard contains a view of the list of file names; actions have already been added to maintain the list of file names – records can be added, updated and deleted (this is simply a view on the Stream Billing report list)
You will add an action to run the file load based on the record selected from the list of file names. First you need to create a Task Plan to load the reports:
- Create a Task Plan called Load billing report
- Add an Analysis Task to run the Stream Billing reports
- Run the Task Plan to check that it loads data into the Stream
Set the element name of the view on the dashboard:
- Open the dashboard Manual billing reports load
- Press on the view File List to show the view details on the dashboard
- Update the Element Name to: FileList
- Press
- Press
Now create the action:
- Open the configuration form for the Stream Billing report list
- Go to the Actions tab
- Press to create a new action
- Give the action the following configuration:
- Name: Load billing report
- Display Name: Load report
- Run Selected TaskPlan: Load billing report
- Press
- Add a context parameter to the action:
- Go to the Context Parameters tab
- Press
- Configure a context parameter with the settings:
- Name: FileName
- Expression: FileList.FileName
Note that to reference the selected row, we use the Element Name of the view on the dashboard
- Press
- Press in the main Action configuration form
- To associate the action with the view:
- Open the configuration form for the view File List
- Go to the Menu tab
- Press - Actions
- Drag the action Load report into the list of actions on the view
- Press to apply your changes
- Open the configuration form for the view File List
Now update the file collector so that it loads the file selected in the dashboard:
- Open the configuration form for the File Collector Manual billing reports load by double-clicking it on the model view
- Update the File Pattern Expression to: _context.FileName
- Press
Test the action:
- Close the dashboard Manual billing reports load and then re-open; the new button will appear
- Add at least one row to the file list (remember you can see the list of files available in the input directory), e.g. billingReport_1.txt
- Select a row, and run the action Load report
- Check that the data for that file (and only that file) was loaded