Brian Mann
|
Posted: 01/13/2002, 5:04 AM |
|
Have posted this to newsgroup but just in case someone can help a new CC user:
I wanted to implement a logical delete function that worked off the DELETE
button that CC would generate on any given page. That is, instead of
physically deleting the record I want CC to update a deleted_datetime and
deleted_by fields which I have on all my tables. Should I be using "Custom
Action" and how can I prevent/override the normal delete function.
* Note: deleted_datetime should be date & time that the delete button was
pressed and deleted_by should contain the user login name of whoever is
logged on.
Thanks
Brian
|
|
|
Ken Hardwick
|
Posted: 01/13/2002, 5:47 AM |
|
Brian,
You can create your own sql to be executed when "delete" is clicked.
To do so, set the value of "sSQL" in the "Before Delete" event.
Something like..
sSQL = "Update YourTableNuame set "
sSQL = sSQL & "[deleted_datetime] = " & now()
sSQL = sSQL & ",[deleted_by] = " & toSQL(Session("userid"),"TEXT")
sSQL = sSQL & " where " & swhere
Note: If you will review the ASP code as generated by CC, that before CC creates the value for "sSQL", it checks to see if it is blank..if it is not
blank, then it does not create the value...for instance, see the code below
if sSQL = "" then
sSQL = "delete from Members where " & sWhere
end if
So, if you create a value for sSQL before this, then your sSQL is used as you created in the "before" event. Pretty cool/smart by the CC programers...
Ken Hardwick
www.kenhardwick.com
Norman,Ok
|
|
|
|