I have an event that, once a record is updated, a message appears on the screen like "An email has been sent to the employee".
However as the table is based on a query that will only display records with a status of "Not Approved". This means that once a record's status is changed in the edit screen to "Approved", "Declined" or "Waitlist", it will be removed from the list page. This all happens so quick that the message that is supposed to appear on the screen doesn't. I have copied the relevant code below. Is there any way of changing this so that the message appears before the screen reverts back to the List page?
' After record updated
Function AfterEdit(ByRef values,where,ByRef oldvalues,ByRef keys,inline)
Dim dict
Set dict = values
'** Send email with new data ****
' do not forget to setup email parameters like From, SMTP server etc
' on 'Security->User login settings' dialog
Dim dkeys, tmpDict, msg, n
msg ="This is an auto generated email to advise of your Leave Application status." & vbcrlf
msg = msg & "" & vbcrlf
msg = msg & "ID: " & dict("ID")& vbcrlf
msg = msg & "Name: " & dict("Name")& vbcrlf
msg = msg & "Staff No: " & dict("StaffNo")& vbcrlf
msg = msg & "Port: " & dict("Port")& vbcrlf
msg = msg & "Leave Start Date: " &format_shortdate(db2time(dict("LeaveStartDate"))) & vbcrlf
msg = msg & "Leave End Date: " &format_shortdate(db2time(dict("LeaveEndDate"))) & vbcrlf
msg = msg & "Leave Type: " & dict("LeaveType")& vbcrlf
msg = msg & "Leave Status: " & dict("LeaveApproved")& vbcrlf
msg = msg & "Comments: " & dict("Comments")& vbcrlf
msg = msg & "Approved/Reviewed By: " & dict("ApprovedBy")& vbcrlf
msg = msg & "Approved/Reviewed Date: " &format_shortdate(db2time(dict("ApprovedDate")))& vbcrlf
msg = msg & "" & vbcrlf
msg = msg & "Should you have any queries regarding this email, please direct them to your Manager - " & dict("ManagerEmail") & vbcrlf
if values("LeaveApproved")= "Approved" then
set tmpDict = CreateObject("Scripting.Dictionary")
tmpDict("to")=dict("Email")
tmpDict("cc")=dict("ResourcePlanner1")
tmpDict("cc")= tmpDict("cc") & ";" & dict("ResourcePlanner2")
tmpDict("subject")="LEAVE APPLICATION STATUS"
tmpDict("body")=msg
set ret=runner_mail(tmpDict)
message="An email has been sent to the Employee & Resource Planner/s"
ElseIf values("LeaveApproved")= "Declined" then
set tmpDict = CreateObject("Scripting.Dictionary")
tmpDict("to")=dict("Email")
tmpDict("subject")="LEAVE APPLICATION STATUS"
tmpDict("body")=msg
set ret=runner_mail(tmpDict)
message="An email has been sent to the Employee"
ElseIf values("LeaveApproved")= "Waitlist" then
set tmpDict = CreateObject("Scripting.Dictionary")
tmpDict("to")=dict("Email")
tmpDict("subject")="LEAVE APPLICATION STATUS"
tmpDict("body")=msg
set ret=runner_mail(tmpDict)
message="An email has been sent to the Employee"
if not ret("mailed") then
response.write ret("message")
end if
end if
End Function ' AfterEdit
arrEventTables("AfterEdit")="FormSubmissionsS2SL"
arrAvailableEvents("AfterEdit")=true