Monday 3 November 2014

Create Simple K2 SmartForm

Open K2 Designer
(Click Start menu-->K2 Blackpearl-->K2 smartforms-->K2 Designer
Now we will create category based on project
In the K2 Designer, left side you can see "K2 Designer" root node, expand.
Right click on "All Items", click "New Category"
Enter some Name Ex: MyProject
Under "MyProject" create new categories
Called "Forms", "SmartObjects", "Views", "Workflows"
Right click on "Views"
Select "New View"
Click "Next" at "Introduction" screen
On the General screen, configure the new View.
Ex:
Name :Hello World
Category: MyProject\Views
View Type: Item View
Data Source: (leave blank)
Click Next. You should now be on the Layout screen.
On the Layout screen, click the Create Layout Table Only link and create a table with 2 rows and 2 columns.
From the Controls, panel, drag a Label control into the left-hand side of the table.
Use the Properties pane to change the Text property of the label to Hello World
Drag a Button control onto the form and drop it below the Hello World label
Use the Properties pane to set the Button’s Text Property to Hi

Now Add a Rule to the button...
Select the button you added in the last step, and then click on the Rules tab on the Properties panel to access the Button’s Rules
Click on the Add Rule button to start configuring a Rule. The Rules wizard configuration screen opens.
Because we selected a button when configuring the Rule, K2 already assumed that we want to define a Rule for the Button’s Clicked event. That is correct, so click Next
There are no Conditions we want to set for this Rule, so click Next
On the Actions step, click on the Show a Message Action under the Notifications category. You can either browse for the Action, or type message into the Search box and click the search icon to find the action.
Click on the Configure link in the Rule Definition section to set up the text for the message.
Configure the Show a Message to the User screen with the following options. Note that, for the Body section, we will drag a field from the context browser to show the current user’s Display Name.
Message Size :Small (320 x 240)
Message Type :Default
Title :Hello World
Heading : Hi
Body :Hello, [Display Name]
[Display Name] ---Drag from Context browser-->System Values-->Current user-->Display Name
Click OK to save the rule configuration and then click Finish to finish the Rule Wizard Configuration screen.

You have finished setting up the View, so click Next and then Finish.

After the View is saved, click the Run link to test the new View (You could also click either of the Designtime URL or Runtime URL links in the view properties screen as well)
Click the Hi button and confirm that a dialog box is shown. Notice that the current username is included in the message. Click OK to close the message box.

Create a Form to host the View:
In the category browser right click the "Hello World" View and select Generate Form.
Configure the Generate Form dialog box as follows.
Category :MyProject\Forms
Form Name :Hello World Form
Save the Form:Hello World
Click the OK button to create the new Form. The new Form is added to the category browser. This Form will contain the Hello World View that we created earlier. Notice the little green arrow indicating that the Form is currently checked-out. We must check the Form in before other users will be able to use it.
In the category browser, right-click the Hello World Form and select Check-In. Click OK on the warning message dialog that might appear.

Run the Form
In the category browser, locate the new Hello World Form we created in the previous step and select the Form. IN the Properties panel, copy and paste the Form's runtime url into notepad.
The URL should be something like:
http://k2Server.com/Runtime/Runtime/Form/Hello+World+Form/
Give this url to another user, and test it..