Aimee,

This works for me:

<!--- application.cfm --->
<cfapplication name="myapp">

<CFIF NOT IsDefined("APPLICATION.Counter")>
 <CFLOCK TYPE="Exclusive" SCOPE="application" TIMEOUT="15">
  <CFSET APPLICATION.Counter = 0>
 </CFLOCK>
</CFIF>

<!--- form.cfm --->
<form name="frmTicket" action="frm_action.cfm" method="post">
    <input type="submit" value="Save Ticket">
</form>

<!--- action.cfm --->

<!--- Increment counter --->
 <CFLOCK TYPE="Exclusive" SCOPE="application" TIMEOUT="15">
  <CFSET APPLICATION.Counter = APPLICATION.Counter + 1>
 </CFLOCK>

<!--- Get counter value --->
<CFLOCK TYPE="ReadOnly" SCOPE="application" TIMEOUT="15">
 <CFSET Counter = APPLICATION.Counter>
</CFLOCK>

<CFIF Counter MOD 7 EQ 0>
<!--- send survey email --->
 Counter = <cfoutput>#counter#</cfoutput><br>
 <a href="">Survey Link</a>
<CFELSE>
 Counter = <cfoutput>#counter#</cfoutput>
</CFIF>

~Dina

  ----- Original Message ----- 
  From: Clark, Aimee 
  To: CF-Talk 
  Sent: Tuesday, November 26, 2002 4:42 PM
  Subject: RE: Using a counter variable


  Mosh,
  I tried this and it did work, but, it's still showing my survey link
  even though the counter has been set back to 0. Can you tell why?

  <cflock type="READONLY" name="lckReadCounter" timeout="20">
  <cfset counter = application.counter>
  </cflock>

  <cfif application.counter mod 7 eq 0>
  <cflock type="EXCLUSIVE" name="lckWriteCounter" timeout="20">
  <cfset application.counter = 0>
  </cflock>
  <cfmail query = "GetCall" to="[EMAIL PROTECTED]"
  from="[EMAIL PROTECTED]"
          subject="Closed Help Desk Ticket"
          type="HTML"><body link="red" alink="red" vlink="red">
  Your Help Desk call (Ticket No. #GetCall.ID#) has been
  closed.  If you believe the call should not be closed, or the problem occurs
  again, please reply to this message or call the Help Desk, to let us know.
  <P>
  <div align="center"><H3>Call Information</h3></div><P>
  <h4><b><font color="Red">Ticket Number:</font></b>  #GetCall.ID#<P>
  <b><font color="Red">Problem Description:</font></b>  <BR>
  #GetCall.Issue#<P>
  <b><font color="Red">Resolution:</font></b> <BR>
  #GetCall.Resolution#<br><br>
  <P></h4></body>
  <div><font color="Red"></font><a
  href="http://dailynews/helpdesk/test/HDSurvey.cfm?ID=#ID#";
  target="_blank">Click here to answer a brief survey about your issue and
  resolution.</a></font></div>
  <p>#counter#</p>
  </cfmail>

  <cfelse>
  <cflock type="EXCLUSIVE" name="lckWriteCounter" timeout="20">
  <cfset application.counter = application.counter + 1>
  </cflock>
  <cfmail query = "GetCall" to="[EMAIL PROTECTED]"
  from="[EMAIL PROTECTED]"
          subject="Closed Help Desk Ticket"
          type="HTML"><body link="red" alink="red" vlink="red">
  Your Help Desk call (Ticket No. #GetCall.ID#) has been
  closed.  If you believe the call should not be closed, or the problem occurs
  again, please reply to this message or call the Help Desk, to let us know.
  <P>
  <div align="center"><H3>Call Information</h3></div><P>
  <h4><b><font color="Red">Ticket Number:</font></b>  #GetCall.ID#<P>
  <b><font color="Red">Problem Description:</font></b>  <BR>
  #GetCall.Issue#<P>
  <b><font color="Red">Resolution:</font></b> <BR>
  #GetCall.Resolution#<br><br>
  <P></h4></body>
  <p>#counter#</p>
  </cfmail>
  </cfif>

  Thank you,
  Aimee' Clark

  -----Original Message-----
  From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, November 26, 2002 3:41 PM
  To: CF-Talk
  Subject: RE: Using a counter variable


  You haven't made your counter variable persistent.  Every time someone makes
  a new request of your application, Application.cfm creates a new variable
  called "counter" and sets it equal to 0.  You need to make your variable
  persistent.  And since you want it to work across multiple users, it should
  probably persist in the APPLICATION scope.

  So, your Application.cfm should look something like:

  <CFIF NOT IsDefined("APPLICATION.Counter")>
  <CFLOCK TYPE="Exclusive" NAME="lckCreateCounter">
  <CFSET APPLICATION.Counter = 0>
  </CFLOCK>
  </CFIF>

  Your action page should look something like:

  <!--- Get counter value --->
  <CFLOCK TYPE="ReadOnly" NAME="lckReadCounter">
  <CFSET Counter = APPLICATION.Counter>
  </LOCK>

  <CFIF Counter EQ 6>
  <!--- Increment counter --->
  <CFLOCK TYPE="Exclusive" NAME="lckWriteCounter">
  <CFSET APPLICATION.Counter = 0>
  </CFLOCK>

  <!--- ***** show survey code ***** --->
  <CFELSE>
  <!--- Increment counter --->
  <CFLOCK TYPE="Exclusive" NAME="lckWriteCounter">
  <CFSET APPLICATION.Counter = APPLICATION.Counter +
  1>
  </CFLOCK>
  </CFIF>


  --
  Mosh Teitelbaum
  evoch, LLC
  Tel: (301) 625-9191
  Fax: (301) 933-3651
  Email: [EMAIL PROTECTED]
  WWW: http://www.evoch.com/


  > -----Original Message-----
  > From: Clark, Aimee [mailto:[EMAIL PROTECTED]]
  > Sent: Tuesday, November 26, 2002 4:03 PM
  > To: CF-Talk
  > Subject: Using a counter variable
  >
  >
  > 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?
  >
  > Thank you,
  > Aimee' Clark
  > Web Developer
  > Stinson Morrison Hecker
  >
  > 

  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to