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:

Code Block
languagesql
CREATE TABLE HelloWorld_UsersDemo (
FirstName         NVARCHAR(120),
LastName          NVARCHAR(120),
DomainDescription NVARCHAR(128),
UserDescription   NVARCHAR(128),
Email             NVARCHAR(128),
)
GO

Once the table is created, automatically the ID attribute will be generated by default including the procedures to manage the information stored in the Database for this table. These are the set of store proceduresOne of the best Wayfast features is its Database framework which takes care of repetitive tasks to make Dev’s life easier and make development process super fast.

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 DELTE. After creating the aforementioned table you can see the following stored procedures in your DB:

  • spWF_HelloWorld_UsersDemo_CreateOrUpdate

  • spWF_HelloWorld_UsersDemo_Delete

  • spWF_HelloWorld_UsersDemo_Get

For this example exercise we will use “spWF_HelloWorld_UsersDemo_CreateOrUpdate.

Info

NOTE: Keep in mind that if you alter these stored procedures and then alter the table structure these SPs will be generated again and you will loose your changes.

Let’s go back to Wayfast Editor and Update Wayfast DB Model.

...

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.

...

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.

...

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.

How the Application works after all the definitions?

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.