What is a Save Action?
The Save action inserts or updates records into a specified table.
If the Save action has Auto Save Attributes enabled, this saves unmapped attributes from the input form or view, matched by the primary key. The primary key must be mapped. Where it is empty, a new record is inserted but if it is populated, the existing record is updated.
Note: Save actions will only insert or update records in tables with a Period 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).
In this example, we are using:
- A Course Form screen containing form fields and associated with School Courses data by a background filter - the screen was created using the Edit Form template
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Foundation Application. For this example, we'll be configuring a button on the Course Form screen.
We want to be able to save new courses and edit existing ones on a Course Management screen. To do this, we will configure a Save Action on an input form, Course Form screen, that saves the data to the School Courses table. GIF
Save Action to Add and Edit Data
Create a Save Action to save data to the school courses table.
- On the screen where the Actionflow will be initiated from, 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 under Connections and for the input, choose the Course Form data source, 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 and return to the Course Management screen
- Click or to open the Course Form and enter/change the course details, then press to see the Actionflow in action
- We can see that the Actionflow is working because the School Courses grid on the Course Management screen is updated with the data we have just created/edited