This topic is locked

default values in add

8/20/2008 11:48:12 AM
PHPRunner General questions
stanl author

I'm sure what I am trying to do is very simple, but just can't understand. If you can give me some pointers on how to do it or where to look to understand session variables I would appreciate it.
I have a simple form for adding a record with 3 fields
task_id (autonumber)

task_parent (int)

description (text)
task_id is not visible in the add form since it is the primary key
I do not want task_parent to be visible, but have it's value default to the task_id autonumber
description is just a standard text box.
Any help is greatly appreciated.
Stan

N
nix386 8/21/2008

if you insert the value for task_id (autonumber) into task_parent (int) when adding or updating a record isn't that double handling?

just trying to get an idea of what is it that you are trying to accomplish?

stanl author 8/21/2008

if you insert the value for task_id (autonumber) into task_parent (int) when adding or updating a record isn't that double handling?

just trying to get an idea of what is it that you are trying to accomplish?


I am interfacing with an existing system (dotprojet). The table is a table of tasks with the field for task parent to be specified This enbles task grouping by parent and child. If the task_id and task_parent are the same then there is no parent, otherwise the task_id of an existing task would be used and become the parent.
Upon entry I want the task_id and task_parent to be the same and allow a project manager to decide if the task should have a parent or not later.
Hope this clarifies?

J
Jane 8/21/2008

Stan,
you can update your table and fill task_parent field in the After record added event on the Events tab. Here is a sample:

global $conn,$strTableName;

$id = mysql_insert_id();

$strUpdate = "update ".$strTableName." set task_parent=".$id." where task_id=".$id;

db_exec($strUpdate,$conn);

stanl author 8/21/2008

Stan,

you can update your table and fill task_parent field in the After record added event on the Events tab. Here is a sample:


Jane,
Thank you!
This is exactly what I was looking for. One question, if the table is a Custom View rather than an actual table in the database, what would the global variable be?
$strTableName refers to the custom view and returns an error table not in database. If I hard code for the table name it works great.
Thanks again!

Stan

J
Jane 8/22/2008

Stan,
if you use custom view created in the PHPRunner replace $strTableName with your actual table name in the event code.