Clark, Aimee writes: > I have an application in which I want every 7th record closed in a table to > generate an email asking the user to participate in a survey. > > I have <cfset counter = 0> in the application.cfm file. > > I have <cfset counter = counter +1> in my action page right after an update > that is done to the table. > > Then I have <cfif counter EQ 7> > execute generating email > then it resets the counter back to 0 > > However my counter is not incrementing at all. It just keep staying at 1. > I'm not sure why. Can someone provide some assistance with this?
Aimee: The problem is that Application.cfm is always run before any template in the same directory (or subdirectory that does not have its own Application.cfm). So essentially the variable 'counter' is being set to 0 each time the page loads. It's also being set within the local scope, so it wouldn't really be persistent. In your Application.cfm, cfparam the variable (within the application scope) as follows: <cfparam name="application.counter" default="0"> then, on your form's action page, you don't really want <cfif application.counter EQ 7>, as that would only trigger once. You want <cfif application.counter MOD 7 EQ 0>, which says every 7th time, trigger event. This will work until the application times out...not sure if that's what you want or not. You might just want to have a value in a database increment by one for every insert...and if that value is evenly divisible by 7, run your survey code. hth, charlie ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

