This topic is locked

Before Add Event - Send Email

1/5/2007 3:06:15 PM
ASPRunnerPro General questions
J
jtforstner author

2 tables = Requests & Users
Requests holds database entries

Users holds user account login, password & email
On the add page the "EnteredBy" field autopopulates using the default value of Session("UserID")
How do I create an After Record Update event on the Edit page that checks to see if "FIELD1" has been changed from the default value of 'Unanswered' and e-mail to the user indicated in the EnteredBy field?
Thanks,
Jeremy

J
jtforstner author 1/5/2007

2 tables = Requests & Users

Requests holds database entries

Users holds user account login, password & email
On the add page the "EnteredBy" field autopopulates using the default value of Session("UserID")
How do I create an After Record Update event on the Edit page that checks to see if "FIELD1" has been changed from the default value of 'Unanswered' and e-mail to the user in the "EnteredBy" field?
Thanks,
Jeremy


Also, I would like the e-mail sent to provide the value of the "Autonumber" field (which is the key field") so that the entering user can go back to the search page, enter the autonumber and find the request that was updated.
Thanks again for all your help and an excellent product.

Sergey Kornilov admin 1/7/2007

It's hard to understand if you talking about adding or editing a record.
In case of Add you can use something like this in AfterAdd event:

set rstmp = Server.CreateObject("ADODB.Recordset")

rstmp.Open "select * from TableName where ID = (select max(id) from TableName)", dbConnection
if rstmp("FIELD1")<>"Unanswered" then
sendemail rstmp("EnteredBy"), "subject", "message"
end if
rstmp.close : set rstmp=nothing
J
jtforstner author 1/8/2007

It's hard to understand if you talking about adding or editing a record.

In case of Add you can use something like this in AfterAdd event:

set rstmp = Server.CreateObject("ADODB.Recordset")

rstmp.Open "select * from TableName where ID = (select max(id) from TableName)", dbConnection
if rstmp("FIELD1")<>"Unanswered" then
sendemail rstmp("EnteredBy"), "subject", "message"
end if
rstmp.close : set rstmp=nothing


Sergey,
It would be editing a record. Basically, if someone goes in and changes "Field 1" in an existing record. How do I create an event that e-mails "EnteredBy" a message saying: Record "RequestID" has been updated.

J
Jane 1/9/2007

Jeremy,
here is a sample code for the Before record updated event:

Function BeforeEdit(dict, where)

email=dict("EnteredBy")

message = "Record " & dict("RequestID") & " has been updated."

subject="Sample subject"

sendmail email, subject, message

BeforeEdit = True
End Function