Need help with Form style Data Entry UI

Is there a tutorial that shows how to build a basic data entry form and update to database? I know this has to be something simple I am overlooking.

In a nut shell:
I want to be able to open a container, with several fields. I would like to have some fields auto populate (like with a text field named user having the text system.security.getUsername() on page load), I would like other fields to have dropdowns tied to datasets.

I would like for users to be able to click a button and have a new record created or have an existing record updated.

I don’t see anything that shows how to set up anything like this.

This is a pretty normal thing to to in Ignition, and it’s fairly straight forward.

To auto-populate fields, simply bind them to an expression or a non-polling query that provides their initial value. (The username could be gained using a runScript expression).

Populating dropdowns is a simple matter of binding their dataset property to a query that returns the appropriate options.

And then the button to commit the form would be written as an actionPerformed script that gathers all of the fields and then runs a system.db.runUpdateQuery command passing in the field values as query parameters.

Let us know if you get stuck anywhere.

Ok, this is where I am stuck. I know how to create the fields and assign scripts when actions are performed. I don’t see the initial actions, like an on page load.

For the database runUpdateQuery function. Where do I declare the db connection? What language is used in the example. The examples only seem to use two parameters but it is defined with four.

ok… so let me give a limited example and maybe you can give me some code to match. I am sorry that I am slow to pick this up.

Let’s say have have a MSSQL db “testdb” and a table “tbl_Request”.
The table has Primary key field named “ID” type int with auto increment, field “user” varchar(20), field “request” varchar(MAX).

On my page I have a text box “user_textbox”, a text field “request_textfield” and a button “add_new”.

Help me place the system username in the “user_textbox” when the page loads. Help me insert the text from the “user_textbox” and the “request_textfield” into the “tbl_Request” table when the “add_new” button is clicked.

This would help me a lot. This will help me understand and rapidly expand.

Ok to place the username in the user_textbox you would bind the text property of the component to the following expression:{[System]Client/User/Username}When the window opens the binding will automatically happen and the username will be the default value. The user can overwrite it if they want to.

Next, add the following script to the add_new button (right click on the button and select Event Handlers… and then the actionPerformed event under action and lastly the script editor tab):[code]user = event.source.parent.getComponent(“user_textbox”).text
request = event.source.parent.getComponent(“request_textfield”).text

system.db.runPrepUpdate(“INSERT INTO tbl_Request (user, request) VALUES (?,?)”, [user, request])
system.gui.messageBox(“Request added”)[/code]If you need to specify a different database connection than the default for the runPrepUpdate do the following:system.db.runPrepUpdate("INSERT INTO tbl_Request (user, request) VALUES (?,?)", [user, request], "testdb")That is it. Hope that helps.

Thank you so much. I will try this when I get back to my environment.