Overview
The purpose of this lesson is explain the Actions in Wayfast. In previous lessons, we analyzed how to create controls and how they are connect to dataset. Actions will be connected to those entities when the application user has to interact with the interface. These These actions are events that allow us to interact with our Project database. We can establish a connection between any action with a control.
...
Preconditions
We need to create a In previous lessons, we talked about Dataset and Controls and how we can create them in our project’s page. Let’s review what are the necessary controls to make the interaction between the app and database:
Inputbox: This control will allow us to insert data into our Project DBdatabase
Button: This control will trigger the insert and it should be connected to the Action that we are going to create
Grid_column: This control will display the values that we have stored into our Project DB
...
database
Following this instructions, we can easily build and connect any form page to fill information in minutes.
...
Click on “Preview” button to verify how the application is depicted in developer environment.
...
Also Now that we have the page created, we will need a Stored Procedure is needed to save the input information in the frontend. See that the @Data1 and @Data2 are connected to the inputbox controls and the grid_column controls previously created in Wayfast. Once that the Stored Procedure is created, we can go back to Wayfast application and synchronize the Stored Procedure in the environmentLet’s navigate to our database manager, in this example, we are going to open the SQL Server Manager to create the stored procedure. Make sure that we are pointing to the right database that we associate to this project in Wayfast.
Code Block | ||
---|---|---|
| ||
CREATE PROCEDURE spHola_Mundo_AccionesTest_Insert
@Data1 nvarchar(50)
@Data2 nvarchar(50)
AS
BEGIN
INSERT Hola_Mundo_AccionesTest(Data1,Data2)
SELECT @Data1, @Data2
END
GO |
Click @Data1 and @Data2 are connected to the inputbox controls and the grid_column controls previously created in Wayfast. Once that the Stored Procedure is created, we can go back to Wayfast application and synchronize the Stored Procedure in the environment.
Focus on any active requirement and click on “End Task” button related to Project’s requirement.
...
This step is only needed for synchronization of the new Table and Stored Procedure generated in DBdatabase.
...
Now we have the new objects available in Wayfast Application to associate with Controls and Actions.
How to create new Action?
Return to Page’s information details.
...
Complete the “Name of the Action” field with the identification for this new action, then select “Stored Procedure” in “Action Groups” since we created a SP stored procedure in our DB database for this purpose. After we select the option, Wayfast will display 2 options on “Action” field:
FORM is used in Wayfast as unique execution in the whole page.
LIST is an action that can be executed as many times that it’s requested. Mostly this is needed when the page has multiple registries in grid views.
In this caseexample, we are going to execute the action over the entire form.
Make sure that the search on “Stored Procedure” lookup field remain the created SP stored procedure in DB. Automatically Wayfast database. Once we select the right procedure, we can observe that Wayfast automatically detect the SP parameters: “Data1” and “Data2”.
...
Click on “Accept” and the new action is created and connected to the Application.If you want to check
Run the app
Let’s verify the new action under running the application, let’s click on “Preview” button on the page and input new values. Then click on “Add” button which is the control associated to the action that we made recently.
...
Info |
---|
We can verify in the DB that In case we want to verify that the functionality is working as expected in database, open the SQL Server Manager and check if the table has the new input values inserted through the app. |
How to update Dataset with new Action created?
If the action created and linked to the control (button) is updating the DB but the new data is not displayed One of the common scenarios in the interaction between dataset and actions is the one where the database is updated with new input values but it's not reflected on screen at the moment that was logged, triggered. Let’s analyze what we need to check and how the new action is connected to the Dataset.
Click Focus on “Dataset” section and click on “Edit” icon related to the corresponding dataset in Page’s detail.
...
A popup is displayed with dataset information. Turn to “Data Binding” tab
...
Input new data and click on “Add” button. Every time that we click on the button, the Dataset will be executed and consequently, the information will be refreshed in the grid.
In few minutes, we setup a form to store all the information that we want in database and what is better, this new data is available in real time on the frontend for all the users.
Recap
In the first part, we revised the preconditions to create pages with a basic structure (dataset and controls) and then we learnt about how to create new actions that can be related to these Controls previously added. In the second part, we verified how the interaction is executed in the application environment and how this can be edited to adjust the interaction regarding what we display and what we insert in the database.