Creating a To-Do Item

Now let's look at how to create to-do items. The procedure is pretty much the same as it is for a project.

Locate uiCreateToDo in the Card Script

In the card script you will find a uiCreateToDo command.

Update uiCreateToDo Command

Replace the uiCreateToDo command in the card script with the RevTalk code below. After you insert the code we will go through the relevant parts.


Copy & Paste The Following Code


command uiCreateToDo

put the uSelectedProjectID of group "ProjectsPeople" into theProjectID

if theProjectID < 1 then

put "no project selected" into theError

end if

if theError is empty then

## Create new SQL Record object for todo_items table

put sqlrecord_createObject("todo_items") into theRecordA

## Set properties of object

sqlrecord_set theRecordA, "name", "New Task"

sqlrecord_set theRecordA, "project_id", theProjectID

sqlrecord_set theRecordA, "sequence", NextSequenceForProject(theProjectID)

## Create record in the database

sqlrecord_create theRecordA

put the result into theError

end if

## Add new record to Data Grid and open for editing

if theError is empty then

## Refresh list, select new record and open field editor

## so that user can change name.

lock screen


set the uSelectedID of group "ToDo" to theRecordA["id"]

set the dgTemplateFieldEditor["select text"] of group "ToDo" to true

dispatch "EditKeyOfIndex" to group "ToDo" with "name", the dgHilitedIndex of group "ToDo"

unlock screen

end if

if theError is not empty then

answer "Error creating to-do item:" && theError & "."

end if

end uiCreateToDo

Creating a To-Do Item

This command needs to add a to-do item to the todo_items table in the database. The steps are the same as the ones you followed to create a project. The only difference is that when creating a to-do item you must link it to a project (1) using the id of the currently selected project.

Test Record Creation In The Database

With New Project selected in the left column click the Add To-Do button. This button has been hooked up to call uiCreateToDo. YOU WON'T GET ANY VISUAL FEEDBACK AT THIS POINT.

Verify Result

You can verify that the new record was created using your SQLite manager program. Look at the records for the todo_items table.


Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.