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.
![](https://media.screensteps.com/image_assets/assets/000/139/138/original/media_1253894672549.png)
Locate uiCreateToDo in the Card Script
![](https://media.screensteps.com/image_assets/assets/000/139/130/original/media_1253763960822.png)
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
RefreshToDoList
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
![](https://media.screensteps.com/image_assets/assets/000/139/134/original/media_1253889964345.png)
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
![](https://media.screensteps.com/image_assets/assets/000/139/136/original/media_1253764531768.png)
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
![](https://media.screensteps.com/image_assets/assets/000/139/132/original/media_1253764589501.png)
You can verify that the new record was created using your SQLite manager program. Look at the records for the todo_items table.
0 Comments
Add your comment