if you are using an incremental key for each new record - you could use a 
mod 7 on the primary key to determine if the record should be selected for 
survey followup.

<cfif mod(recordID,7) is 0>send additional</cfif>

e

From: "charlie griefer" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: CF-Talk <[EMAIL PROTECTED]>
Subject: Re: Using a counter variable
Date: Tue, 26 Nov 2002 14:43:48 -0700

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
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to