Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Overview

Wayfast Actions allow executing process or communicating with external systems incluiding databases, APIs or executing DLL methods. In this lesson we will review how to create an action to save data in a table with a Stored Procedure.

Preconditions

Step 1: Create a Table

Open SQL Server Management Studio and run the following script:

...

When a table is created Wayfast adds an ID attribute to make sure that consistency in the database can be enforced. At the same time it will create three stored procedures to manage classic CRUD operations: CREATE, REMOVE, UPDATE AND DELTEDELETE. After creating the aforementioned table you can see the following stored procedures in your DB:

...

A popup is displayed, click on “Synchronize” button. Now the stored procedure created in database will be available to connect with dataset.

...

Step 2: Setup the page

Let’s create a page called “HelloWorldUsers” before creating an action.

...

Click on “Submit” button and we are now ready to create the structure.

Step 3: Setup the Dataset & Controls

Our page should get the information from the table HelloWorld_UsersDemo using a dataset like we learnt in the latest lesson.

...

Let’s move to the controls that we need on this page to display and insert new users. We are thinking on the following structure according to the table that we created in the database:

  1. LABEL: This control will display our header title

  2. INPUTBOX: This control will allow us to insert data into our database. In this example, we are going to create 5 controls, 1 per each attribute in our HelloWorld_Users database table (FirstName, LastName, DomainDescription, UserDescription and EmailDescription)

  3. GRID_COLUMN: This control will display the values that we have stored into our database. Again, we repeat 1 per each attribute in our HelloWorld_Users database table (FirstName, LastName, DomainDescription, UserDescription and EmailDescription)

  4. BUTTON: This control will trigger the new user created and it should be connected to the “Insert” action that we are looking in the example

We can create one inputbox control for reference and then we can repeat the steps for the others needed. Select the “Inputbox” control and click on “New” button. A popup will be displayed to fill the information related to new control.

...

Finally we have the structure finished, click on “Preview” button and check what we created so far

...

How to include Actions in Controls?

We did a lot of work so far, now we are ready to learn the impact functionality that “Actions” feature make on the controls that we generated and how interact with our application.

...

Complete the inputbox fields and click “Add New User” button to insert the new data on the HelloWorld_Users table. If we check on the SQL, the new values are updated:

...

However, we are not able to see the data refreshed on screen. Let’s see what we can do in this case to make the inserted values on the page.

How to update Database with an Action?

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 triggered. Let’s analyze what we need to check and how the new action is connected to the Dataset.

...

Let’s check the results in the example.

...

Let’s test the app

Now that the page is setup with Dataset, Controls and Actions, we can verify that the interaction is working as expected. Wayfast allow us to make a preview by click on “Preview” button at the top right corner

...

Info

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.

Recap

In the first part, we revised the preconditions to create pages with a basic structure (dataset and controls) and then we learnt 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 and how this can be edited to adjust the interaction regarding what we display and what we insert in the database.