« Return to Thread: type beforeSave() afterSave()

Re: type beforeSave() afterSave()

by Jeff Coughlin :: Rate this Message:

Reply to Author | View in Thread


AJ,

Actually Blair and I had this discussion a couple weeks ago.  I  
informally requested to have an additional structure variable with all  
of the object information that existed before the add/edit so that the  
developer can conditionally make decisions in beforeSave() and  
afterSave() (ie. Maybe the variable could be called stPropertiesBefore  
or something more witty :) ).  Blair agreed it would be useful and had  
run into the problem himself, however he said he wanted to run it by  
Matt first (who was away on holiday), but I haven't followed up on it  
yet.

Currently your only option is to use beforeSave() and at the top do a  
getData to compare the data against.

Example (somewhere at the top of beforeSave() ):
<!--- Check to see if data has changed --->
<cfset stObject = getData(objectid=arguments.stProperties.objectid) />

<!--- Now you can conditionally check if data has changed --->
<cfif stProperties.title neq stObject.title>
   <cfset stProperties.title = "Why did you change me?!?! :)" />
</cfif>

Regards,

--
Jeff Coughlin
Web Application Developer
http://jeffcoughlin.com

On Jun 29, 2009, at 11:46 PM, AJ Mercer wrote:

> is there a way with beforeSave() or afterSave() of a type
> to tell if it is a new entry (distinct from update )?
>
> Farcry 5.1.6
>
> --
> AJ Mercer
> Web Log: http://webonix.net
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcry-dev@...
To unsubscribe, email: farcry-dev+unsubscribe@...
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: type beforeSave() afterSave()