jswales
Posts: 4
|
| Posted: 02/24/2007, 8:04 AM |
|
I have an editable grid, that has three hidden fields that on insert will contain default values. Two values are from the URL and one is the UserID. I thought I could use the Before Execute Insert Event, with a Retrieve Value for Variable, setting the Source type to Session/URL and the Source Name to the variable names. I think my problem is that I don't know what to use for the Variable Name option. I"m guessing I need to update the database column before it's inserted.. So my thought is that the variable name should be the database column name, but I guess that's one area I'm a little fuzzy in with this product. Any suggestions?? Should I use custom code instead??
It's been a great experience so far, and I must complement the CCS developers that I have got this far without having to ask any questions.
Thanks.
|
 |
 |
peterr
Posts: 5971
|
| Posted: 02/25/2007, 4:20 PM |
|
Hi,
I think that you'd need to use the "Value for Control" action, as you will be updaing one of controls in the grid.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
jswales
Posts: 4
|
| Posted: 02/25/2007, 9:12 PM |
|
Peterr, I did try that, but have taken a slightly different route. I have it mostly working by using a Before Build Insert Event, with the following Custom code.
//Custom Code @96-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
$timesheet->ds->emp_id->SetDBValue(CCGetSession("UserID", NULL));
$timesheet->ds->store_id->SetDBValue(CCGetFromGet("s_store_id", NULL));
$timesheet->ds->store_id->SetDBValue(CCGetFromGet("s_week_date", NULL));
This works for all except the s_week_date field, which is generating the incorrect date into the database. I am using dependant list boxes the second of which is a date select option that is getting passed through as a URL parameter. It is clearly not making it through all the changes.. :)
Any thoughts on how to get the correct date based by the URL Parameter into the MySQL database??
|
 |
 |
peterr
Posts: 5971
|
| Posted: 02/25/2007, 11:29 PM |
|
I think that the format of your s_week_date must match the format specified in the "DBFormat" property of the field you're updating (or Date Format of your connection).
BTW, I suspect that $timesheet->ds->store_id in your code above was a typo - if you're updating a date field.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
jswales
Posts: 4
|
| Posted: 02/26/2007, 2:41 PM |
|
Peter,
Yup, you are right. Had a typo there. The example should have read:
//Custom Code @96-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
$timesheet->ds->emp_id->SetDBValue(CCGetSession("UserID", NULL));
$timesheet->ds->store_id->SetDBValue(CCGetFromGet("s_store_id", NULL));
$timesheet->ds->week_date->SetDBValue(CCGetFromGet("s_week_date", NULL));
It's the last field I'm having problems with, since it ends up in the incorrect format in the URL. I have a drop down select box with the dates listed. Once selected it brings up my Editable Grid with all the correct matching current records. I want to put the date value from the list into each Insert Record, since the user is not allowed to change/edit the date. I debated if I should somehow use session variables instead of URL variable to pass the date field, or if there was some better way of passing the field.
My URL ends up with: /timesheet_test.php?s_week_date=2/18/2007&s_store_id=1 in it, or sometimes it looks like this: /timesheet_test.php?s_week_date=2%2F18%2F2007&s_store_id=1
I sometimes get a 000 value for a date, and sometimes get an incorrect date. Anyone have any suggestions on how to best pass the date around to be a default in my inserts in an editable grid??
Thanks
Julian
|
 |
 |
jswales
Posts: 4
|
| Posted: 02/26/2007, 9:00 PM |
|
Well, I'm making some progress.. Can someone tell me why the following code is returning the word Array, instead of a parsed date value??
$date_in = CCGetFromGet("s_week_date");
echo "<br>URL Value date_in: " . $date_in;
$date_parse = CCParseDate($date_in, array("m","/","d","/","yyyy"));
echo "<br>Parse Date date_parse: " . $date_parse;
Returns the following output:
URL Value date_in: 2/18/2007
Parse Date date_parse: Array
Thanks.
|
 |
 |
|