This topic is locked

Email Link To New Record

5/10/2011 4:40:12 AM
ASPRunnerPro General questions
M
MrDerp author

I am having difficulty implementing an event that will send the end-user an email with a direct link to a newly added record. I am using an Informix database with a primary key of "Serial" type i.e. it auto-increments when a new record is added.
The "after record added" event I have created looks something like this:



Dim dkeys, tmpDict

msg =""

id = values("id")



set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="nexus-samples@primeur.ltd.uk"

tmpDict("subject")="New Record"

tmpDict("body")="A new record has been added. Please click the following link: http://website-url/Records.asp?editid1="; & id

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if


As you can see from the URL, I would like to link the user directly to the edit page of the newly added record. However, the "id" variable is null when emailed - presumably because the id isn't available until after the "after record added" event.
Is there any way of achieving this? It seems like pretty standard functionality but I can't see how it can be done in ASPRunner.
Any help would be greatly appreciated!

P
Philip 5/10/2011

Try this:
tmpDict("body")="A new record has been added. Please click the following link: http://website-url/Records.asp?editid1="; & values("id")
Regards

Philip

M
MrDerp author 5/10/2011



Try this:
tmpDict("body")="A new record has been added. Please click the following link: http://website-url/Records.asp?editid1="; & values("id")
Regards

Philip


That's what I'm doing now - id = values("id") (as defined at the top of the code snippet).
I can only assume that the ID is not available when the email is triggered. I suppose one way to do it would be to run some SQL to find the last used ID, and simply increment this by 1? Would it be possible to run a custom query in the "after record added" event?

Sergey Kornilov admin 5/10/2011

As manual says in AfterAdd event you can access the value of key column using keys("key column name").
There is a possibility though that it may not work as expected with Informix. In this case you need to execute a SQL query that retrieves the value of this ID.
Another thing - instead of Records.asp in your code you need to use either records_view.asp or records_edit.asp.