As a developer at Data Springs, you can imagine how many different software components we try out for our Development needs when creating solutions for clients. About 2 years ago I have found a Holy Grail development tool called OpenWebStudio(OWS). The more I work with this tool, the more I respect and invest into this development tool. For me it seems that there are endless possibilities with this module. I haven’t been let down yet. This blog post is a tutorial to getting started in OWS and integrating it with Dynamic Forms 4.0.
PREREQUISITES:
* Have an installation of DotNetNuke 5 or above.
* Download OpenWebStudio.
* Purchase Dynamic Forms or use a Dynamic Forms Trial version.
* Install OpenWebStudio and Dynamic Forms onto your DotNetNuke installation.
* Create 1 page, this page will contain a Dynamic Forms module instance and an OpenWebStudio module instance.
GOAL:
* Create a report off of a flat SQL table using OWS
SCENARIO:
* We need to build a form using Dynamic Forms to insert and update Books from flat table. This is going to end up being an Admin control.
GETTING STARTED ON PART 1 OF THIS TUTORIAL
You will need to go to Host-> SQL and create this table.
-------------------
Create Table DynamicForms_LibraryBooks
(
BookID int identity(1,1),
BookName nvarchar(200),
BookDesc nvarchar(2000),
BookCategory nvarchar(200),
DateAdded datetime
)
-------------------
Now that you have created this table, we can get started with the first part.
Step 1
You should have a page with a Dynamic Forms instance placed on it. Now you will need to add the following fields to the Dynamic Form:
Question Name | Short Field Name | Question Type | Default Value | Special Features |
DSParam1 | DSParam1 | Hidden Field | none | Retrieve values from Querystring variable for this question |
DBUpdate | DBUPdate | Hidden Field | False | Retrieve values from Querystring variable for this question |
Book Name | BookName | Text Box | none | none |
Book Desc | BookDesc | Multi Lined Text Box | none | Field width 200px, field height 100px |
Book Category | BookCategory | Text Box | none | none |
Here is an image of the layout:
Now we must create a SQL Form Completion Event that will insert into the SQL Flat Table that we have created. Go to Form Completion Events and add a new Form Completion Event as the type Dynamic SQL Statement. This Completion Event must fire conditionally based on the value of the DBUpdate field. In order for this Form Completion to Execute we will only fire this event when DBUpdate = False. Now we need to build the insert statement. The insert statement will look very similar to the following script.
----------------------------------------------------
Insert into DynamicForms_LibraryBooks(BookName, BookDesc, BookCategory, DateAdded)
Values('$(BookName)', '$(BookDesc)', '$(BookCategory)', getDate())
--------------------------------------------------
The image below depicts the settings and such that the Dynamic SQL Statement should contain.
Now you can insert into the DynamicForms_LibraryBooks flat table when you fill out and submit the form. So this Dynamic Form has now achieved an Insert mode for entering records into our table.
Step 2
Now we will need to work on the Update mode of this Dynamic Form. So we will start by going to Module Configuration –> Advanced Coding Options –> Initial SQL Rendering/ Bind. The SQL query for this SQL bind will be like the SQL query below:
---------------------------------------------------------
Select BookName, BookDesc, BookCategory from DynamicForms_LibraryBooks where BookID = '$(DSParam1)'
---------------------------------------------------------
Take a look at the settings in the image below:
Update Settings after configuring these settings for Initial SQL Binding.
Now we will need to create another SQL Form Completion Event to account for the Update Mode of the Dynamic Form.
Go to Form Completion Events and add a Dynamic SQL Statement event. This event will need to Execute when DBUpdate = True.
The SQL will look like the following below:
---------------------------------------------------------
Update DynamicForms_LibraryBooks Set BookName = '$(BookName)', BookDesc = '$(BookDesc)', BookCategory = '$(BookCategory)', DateAdded = getDate() where BookID = '$(DSParam1)'
---------------------------------------------------------
The image below depicts the settings for this form completion event:
Now our Insert and Update Mode are completed, the next part will be to get an OWS grid to integrate with the work that we have achieved so far.
This concludes part 1 of 3 in this Tutorial. Tutorial Part 2 will be published by Feb 21, 2012.
If you have any questions please leave a comment. Also please let me know if you’re interested in a particular example.
Thanks,
Ryan