By the end of this chapter you will understand what a Save action is and how to use them, and you will have created a Save Actionflow in your application.
What is a Save Action?
The Save action inserts or updates records in a selected table.
Save actions only save attributes mapped into them. NOT SURE WE SHOULD LEAD WITH THIS However, if the Save action has Auto Save Attributes enabled, this saves unmapped attributes from the input form or view, matched by identifier. This finds the attribute associated with a field that was created by dropping the attribute onto a form.
Note: Save actions must be attached to a table with a Type of Transactional. Reword? "Save actions will only insert or update records in tables with the Type of Transactional."
Creating Save Actions
- Click the Save icon in the toolbar to display any existing tables in the application
- Existing tables can be dragged from the Repository onto the canvas, then choose Save to create a Save node
- Alternatively, drag the Save icon from the toolbar onto the canvas
- In the Create Save Action window:
- Enter a name
- Choose a Type:
- Auto Insert/Update - Insert or update records using the following condition:
- If the input data passes in the primary key of an existing record, the save action updates the record in the chosen table
- If the input data does not pass in the primary key of an existing record, the save action inserts a new record in the chosen table
- Insert - Always insert a new record into the chosen table
- Update - Always update a record for the chosen table. For a record to update successfully a primary key must be provided.
- Auto Insert/Update - Insert or update records using the following condition:
- Choose the Table from the drop down where the records will be inserted or updated
- Select Create Action
Worked Example
Here's a worked example using the School Data (available from the Learning Centre). WHAT DOES IT SHOW?
If you are completing this chapter as part of the Actionflow course and using a training instance, this data has already been pre-loaded into the Actionflow Application.
Earlier in this course we created two Open Screen Actionflows that open an input form for adding and editing courses to the School Courses grid. In this example we will configure the Save action.
Note: When creating a new input form in PhixFlow, a Form Actions wizard can configure the Save Record and Delete Record actions for you. For the purposes of understanding the mechanics of Actionflows, we will create these manually.
Save Action to Add and Edit Data
- On the Course Management screen, press either the or button to open the Course Form
- Right-click on the button and choose Add Actionflow
- Enter a name for the Actionflow,
- Name:
Save Course
- Select Confirm
- Name:
- Select Click to Connect and for the input, choose the Course Form datasource, then select Connect Input
- In the Mappings window that opens, drag the CourseID attribute from the left (Course Form) to the right (Input Connection Point)
- Select Save
- Click and drag the Save icon from the toolbar onto the canvas
- In the Create Save Action window enter:
- Name:
SaveCourse
- Type: choose Auto Insert/Update
- Table: choose School_Courses
- Select Create Action
- Name:
- Click and drag the icon onto the Save action node
- Right-click on the in connector and choose Open Mappings
- Drag the CourseID attribute on the left onto the CourseID attribute on the right
- Select Save
- Click on the Save action node and in the Properties, toggle on Auto Save Attributes
- Finally, in the Settings above the canvas, toggle on Close screen after action completes
- Close the Actionflow to return to the Course Management screen
- Lock the screen and press the or button
- Either enter new course details or edit the existing course details and press to see the Actionflow in action
- We can see that the Actionflow is working because the grid is updated with the data we have just created/edited
SCREEN SHOT OF WHAT WAS CREATED?