View Full Version : Email Report After Record Submitted


11-19-2004, 09:48 AM
I am trying to figure out a way to email a report of the record just saved automatically with no button being pushed. I want to do this through WAS since my whole application evolves around web pages. Anyone have any ideals? They would be greatly appreciated.

Selwyn Rabins
11-19-2004, 03:21 PM
if you are using a Dialog component to colled the data and then save a record, then it is pretty straight forward because the Dialog has an AfterValidate event. you can just copy the code from the sample 'email client' dialog that comes in the sample web apps.

if you are using a Grid component, then it is more complicated because (currently), there are no 'events' that the Grid exposes to the developer (we are adding a full event model for the next version).

the Grid component allows you redirect to another page after an update has been processed. You could redirect to another page called (say) report.a5w. This page would contain the xbasic logice to print the report as a pdf and then email it.

the problem that you will face is that you have no way of passing any information to the page that you redirect to. so report.a5w doesn't know which record was just updated.

you could solve this problem by putting a calc field (defined in Field rules) called lastUpdate. you would make this a Time field, and you would set the expression for this field to be:


so, now that you have a timestamp field in your data, all that you have to do is search for the record with the highest timestamp - that is the record that was last updated. to do this, simply order the data on the timestamp field.


t = table.open("mydata")
recno = t.recno()

recno contains the record number of the last record to be updated.

11-19-2004, 05:38 PM
Selwyn thank you for the ideals. Sounds like I need to make a dialog page and then go from there. I currently have records being added thru a grid but can make the changes necessary for a dialog page. Thank You again.