NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: terryd on June 18, 2014, 04:50:09 AM
-
On one of my projects I send an email to the client of the fields values if a new record is added to a specific table.
This is simple since I do it in the postInsert embed point.
What I need to do is to send an email with both the old and new fields if a record is changed.
I can do this in the PostUpdate embed point but what is the best way to:
Firstly know that a change was made since it's possible that the user just came into the form and then saved even though nothing was changed.
Secondly what is the best way to store the incoming values so that I can send an email which says something like: address line was change from (incoming_field) to (current_value)?
-
so I think your problem breaks down into 2 parts;
a) you want to "store" the record, before the save, so you have something to compare to and
b) you need to do the comparison and then build your email from that.
So let's do the easy bits first. You don't actually have to create a copy - one exists already. If, for example your file field is
Inv:Value
then you can access
p_web.GetSessionValue('_old_Inv:Value')
p_web.GetValue('_old_Inv:Value')
to find the original value before the change.
In terms of constructing the email - there's no method to make that easy for you - you just need to compare all the fields which may have changed, or which you want to report have changed.
eg, in Post-Update
if p_web.GetValue('_old_Inv:Value') <> inv:Value
! add to email
end
cheers
Bruce
-
Thanks Bruce. Exactly what I need.
-
Hi Bruce
I put the following trace line in the post update (btw. this is definitely an update, not an insert, the record does exist)
p_web._trace('_old_CLA:ValueInclusive ' & p_web.GetSessionValue('_old_CLA:ValueInclusive') & ' CLA:ValueInclusive ' & CLA:ValueInclusive)
debug view returns this:
[\\TERRYD-PC]
00000003 589.57385254 [16176] [st] [netTalk][thread=3] _old_CLA:ValueInclusive CLA:ValueInclusive 62.55
There is no value associated with _old_CLA:ValueInclusive
-
my mistake Terry, the old value is in the Value queue, not the session queue.
ie
p_web.GetValue('_old_Whatever')
not
p_web.GetSessionValue('_old_Whatever')
Cheers
Bruce
-
Thanks Bruce