This document contains the step-by-step instructions to build the simple "Hello, World" K2 SmartForm. If required, please refer to the Application Design topic for an overview of the SmartForm to understand what the Form does.
In Step 1, we will prepare the K2 category system with folders to store our SmartForm's components (strictly speaking, creating folders is not required, but it is recommended because using a logical folder structure will help to keep the SmartForms environment organized). In Step 2, we introduce you to SmartForms by building a simple SmartForm View that contains some simple formatting and controls, and executes basic Rules. In Step 3, we will build a Form to contain our View and in Step 4, we will test our new SmartForm.
The first step in our Application is to create the categories that will house our form and view. You can think of categories as “folders” that contain things like Forms, Views, SmartObjects and Workflows. While it is not necessary to group elements into folders like we do here, it does help to keep the similar elements organized and grouped, especially for larger Applications that may contain several SmartObjects, Views, Forms and Workflows.
Your category folders should look like the image below when you are done.
In this preliminary step, we created categories ("folders") for the elements of our Hello World Application. Categories are not required, but they do help you keep things neat and tidy, especially as you build larger Applications that contain multiple forms, views, SmartObjects and workflows. In K2 terms, "application" refers to the all of the elements that make up a single project.
We will begin our Form and View construction by building our Hello World View. This View will contain a label, a text box and a button control. The button control will be configured with a rule to show a message after it has been clicked. Remember that views are logical groups of content. One Form might contain several Views. Views by themselves cannot be accessed by users; they must be contained within a Form for your users to access and submit them.
(The Name element in the Properties refers to the control's identity. K2 references controls by their Name value. The Text entry is what the user sees, it is the control's display value.)
Now that we’ve created our basic View and have applied some formatting to the Name Text Box width and table column width, we are ready to add a rule to the Submit Button. We will add a condition to the rule that essentially turns the Name Text Box into a required field, then add an action that shows the user a message after they have clicked the Submit Button.
The first step is to add the Event. Recall that an Event is when something happens. In our case, it’s when the Submit Button is clicked.
In the Rule Designer, notice there are two panes. On the left side are the Events, Conditions and Actions K2 offers out-of-the-box. Navigate to each via the tabs at the bottom of the left-side pane. (A below) On the right side is the Rule Definition pane. This is where you define the conditions and actions for each rule. The rule you are currently working with (When the control is Clicked) is shown at the top of the Rule Definition pane. (B below)
Notice just below the rule title, K2 has added the base rule. Because we had the Submit Button highlighted when we added the rule, K2 added the default method (Clicked) for you. The next step for us is to add our condition to require a value in the Name Text Box.
Now that we’ve configured a condition to require the Name Text Box, the second configuration to our rule is to add an action to show a message. Begin by selecting the Actions tab. (A below)
In the previous step, we scrolled through the Conditions until we found the validation condition. As you work with Rules, you will become more familiar with the terminology. Use the Search box to quickly locate the definition you want to add.
In this next step, we will configure the message we want to show our user. We will be using properties found in the Context Browser. These properties are dynamic, in that at runtime (the live message that the user will see), the properties will be replaced by the appropriate form field or system values. Context Browser properties are always green, so that you can easily find them in your content. In the step below, we will be dragging the Context Browser Name Text Box into our message. At runtime, this value will be replaced be the name entered into the form field. The Current Date system value will be replaced by the actual date.
In Step 2 we created our Hello World View. We added a Label control, a Text Box control and a Button control. We formatted our layout by setting the width of the Text Box control and by adjusting the column width for the View table. We then added a Rule that will fire off when the Submit Button is clicked. We added a Condition to require the Name Text Box and an Action to show a message if the Condition was met.
In Step 2, we created and tested the Hello World View from within K2 Designer. Views must be contained within a Form for our users to be able to access and submit them. In Step 3, we will build a Form for our Hello World View.
(Our simple form probably doesn't need a view title, but when you start building more complex forms with multiple views, giving them meaningful titles can help your user navigate your form elements.)
SmartForms are browser-based forms. If we were to open this form in a browser right now, it would stretch the width of the browser. Because this is a small form, we want to adjust the form’s width so that it is easier to use.
Our final task for Step 3 is to check in the form. Checking in views and forms 'publishes' them to the K2 server, making them available for use by your users. If you need to make a change to either your form or view, you must first check them out, make your edits, then check them all back in again to expose the changes to your users. You can check in views and forms individually, or check in the form, which will include any associated views.
In Step 3 we generated a Form from the Hello World View. We formatted the form by changing the default title bar and by setting the form width. Our form is now ready to be exposed to our users, which we will test in the next step.
In Step 4, we will test our form using an internal link and an external link. The internal link opens and processes the form from within K2 Designer. The external link opens and processes the form from the K2 Runtime Web Site. This is the URL you would use if you were linking to this form from a web page or providing your users with a URL to the Form, for example.
In both cases, confirm the form submitted with the Name Text Box and Today’s Date present in the confirmation message.
Notice how the form opens from within K2 Designer. Enter a name into the Name Text Box and submit the form. Confirm the confirmation message has the name entered along with today’s date.
In Step 4 we tested the Hello World Form both internally and externally. We used the Run link to test the form and observed how it opened and processed from within K2 Designer itself. We then used the Runtime URL link to open and submit our form from an external browser. What's key here is that forms and views must be checked in before your users can access them and users can only access forms from a Runtime URL link. If you need to make a change to a form or view, you must check it out, make your changes, then check it back in. This "publishes" the forms/views to the K2 servers. Users cannot see any changes until the forms and views are checked back in.
Congratulations on building your very first SmartForm! You should now understand the very basics behind Views, Forms, Controls and Rules and how these are used to assemble SmartForms. In other tutorials, we will expand on the Data, Forms, Workflows and Reports components and explain how they are used together to implement K2 applications.
Challenge steps will test your knowledge by providing high-level guidance but no step-by-step breakdown. In this challenge step, you will create a Rule so that the Name Text Box is automatically populated with the current user's name when the Form is opened.
Video | Links | Learn | Support |
No videos found for this article K2 on YouTube
No Additional links found for this article
No self-learning content for this article Try some scenarios...
No relevant support links available for this article
|