Link to home
Start Free TrialLog in
Avatar of smares323
smares323

asked on

Coldfusion 10 EVALUATE

The code below use to work in ColdFusion MX7. Upgraded to ColdFusion 10 and don't work no more.



<CFLOOP INDEX="ListIndex" LIST="#TRIM(UserGroup)#">
            
            <CFSET UserGroup = SpanExcluding(ListIndex, "|*|")>            
            <CFSET UserGroupType = Replace(ListIndex, "|*|","")>
            <CFSET UserGroupType = Replace(UserGroupType, UserGroup,"")>      
            
            
            
            
                  

            <CFSET StartDate = EVALUATE("FORM.StartDate#TRIM(UserGroup)##TRIM(UserGroupType)#")>
            <CFSET EndDate = EVALUATE("FORM.EndDate#TRIM(UserGroup)##TRIM(UserGroupType)#")>
            <CFSET OnGoing = EVALUATE("FORM.OnGoing#TRIM(UserGroup)##TRIM(UserGroupType)#")>
            <CFSET TempEndDate = EVALUATE("FORM.TempEndDate#TRIM(UserGroup)##TRIM(UserGroupType)#")>
            <CFSET SubscriberAcctNumber = EVALUATE("FORM.SubscriberAcctNumber#TRIM(UserGroup)##TRIM(UserGroupType)#")>

            <!--- check SubscriberAcctNumber length and pad with leading zeroes, if necessary --->
            <CFIF IsDefined("SubscriberAcctNumber") AND LEN(TRIM(SubscriberAcctNumber)) GT 0>
                  <CFIF LEN(TRIM(SubscriberAcctNumber)) LT 7 AND TRIM(SubscriberAcctNumber) GT "">
                        <CFSET SubscriberAcctNumberLength = LEN(TRIM(SubscriberAcctNumber))>
                        <CFLOOP CONDITION="SubscriberAcctNumberLength LT 7">
                              <CFSET SubscriberAcctNumber = 0 & TRIM(SubscriberAcctNumber)>
                              <CFSET SubscriberAcctNumberLength = LEN(SubscriberAcctNumber)>
                        </CFLOOP>
                  </CFIF>
            </CFIF>

            <CFQUERY NAME="AddModUser" DATASOURCE="DB">
                  { CALL prMembership       
                        ('#TRIM(UserID)#','#TRIM(UserGroup)#','#TRIM(UserGroupType)#','#TRIM(StartDate)#','#TRIM(EndDate)#','#TRIM(TempEndDate)#','','','#TRIM(OnGoing)#','#TRIM(SubscriberAcctNumber)#')      
                  }
            </CFQUERY>
            
      </CFLOOP>
Avatar of gdemaria
gdemaria
Flag of United States of America image

You forgot to ask a question!

But since you mention evaluate()  you can remove evaluate by doing this...

  <CFSET StartDate = FORM["StartDate#TRIM(UserGroup)##TRIM(UserGroupType)#"]>

instead of this..

  <CFSET StartDate = EVALUATE("FORM.StartDate#TRIM(UserGroup)##TRIM(UserGroupType)#")>
Avatar of smares323
smares323

ASKER

I get this error on the insert.

{ CALL prMembership       ('112973','WSJ','REGULAR','01/01/10,01/01/20','','','','','y,y','') }
That is not an error, what is the error message?

The thing that looks weird is  'y,y'  --- is that supposed to be two "y" ? or just "Y"

same thing with the date..t. here are 2 dates in this quote..

01/01/10,01/01/20
Ok the Evaluate use to filter the multiple records that where submitted.  that's actually 2 grouptype  that were selected and its not looping the startdate  and ongoing for each record. The Y is for the Ongoing field.
In the past the   Evaulate was for more then 1 record that was submitted through the form.

<CFSET StartDate = EVALUATE("FORM.StartDate#TRIM(UserGroup)##TRIM(UserGroupType)#")>
             <CFSET EndDate = EVALUATE("FORM.EndDate#TRIM(UserGroup)##TRIM(UserGroupType)#")>
             <CFSET OnGoing = EVALUATE("FORM.OnGoing#TRIM(UserGroup)##TRIM(UserGroupType)#")>
             <CFSET TempEndDate = EVALUATE("FORM.TempEndDate#TRIM(UserGroup)##TRIM(UserGroupType)#")>
             <CFSET SubscriberAcctNumber = EVALUATE("FORM.SubscriberAcctNumber#TRIM(UserGroup)##TRIM(UserGroupType)#")>
> In the past the   Evaulate was for more then 1 record that was submitted through the form.

Ok, that was the past.  How is it now?  Do you still have more than one record in your form?   How are you looping them now?
Also MX7 the Evaulate would allow each startdate to insert in its own UserGroup record not like this 01/01/10,01/01/20
<!---------------->
<CFPARAM NAME="UserID" DEFAULT="">



<CFIF TRIM(UserID) GT "">

      <CFQUERY NAME="Subscribed" DATASOURCE="db">
            { CALL prUGMembership ('#TRIM(UserID)#') }
      </CFQUERY>      
      <!--- <cfdump var="#Subscribed#"> --->
      
      <CFQUERY NAME="AllGroups" DATASOURCE="db">
            { CALL prUGTypesList }
      </CFQUERY>
      <!--- <cfdump var="#AllGroups#"> --->
<CFELSE>
      <CFABORT>
</CFIF>



      <CFSET GroupList = "">
      <CFSET OnGoingList = "">
      
      <CFOUTPUT QUERY="Subscribed">
            
            <CFSET GroupList = "#TRIM(GroupList)##TRIM(UserGroup)##TRIM(UserGroupType)#,">            
            <!-- 101,239,48,39,932 -->
            <CFIF TRIM(OnGoing) IS "Y">
                  <CFSET OnGoingList = "#TRIM(OnGoingList)##TRIM(UserGroup)##TRIM(UserGroupType)#,">
            </CFIF>            
      </CFOUTPUT>
      

      
      
      
<HTML>
<HEAD>
<Style Type="text/css">
.link1 {text-decoration:none; color:#000000;}
.button0 {font-size:7pt;}
.textEntry1 {font:9pt}
</Style>
</HEAD>

<BODY bgcolor="#ffffff" vlink=blue alink=blue>



<CFOUTPUT>
<FORM name="GroupForm" action="/admin/onlineAccount/userGroupSub.cfm?sid=#sid#&tkn=#tkn#&UserID=#UserID#" METHOD="POST" TARGET="list">
</CFOUTPUT>



<TABLE border=0 cellspacing=0 cellpadding=0 width=99%>
<TR>
<td width=5><spacer type=block></td>
<td>
      
      <table border=0 cellspacing=2 cellpadding=0 width=100%>         
      
      <TR bgcolor="#eeeeee">      
      <td colspan=2><font face=arial,helvetica size=1>
            <u>Available Groups</u>
      </td>
      <td><font face=arial,helvetica size=1>
            <u>Region</u>
      </td>
      <td><font face=arial,helvetica size=1>
            <u>On Going</u>
      </td>
      <td><font face=arial,helvetica size=1>
            <u>Subscriber<br>Account</u>
      </td>
      <td><font face=arial,helvetica size=1>
            <u>Start Date</u>
      </td>
      <td><font face=arial,helvetica size=1>
            <u>End Date</u>
      </td>
      </TR>
      
      <CFOUTPUT QUERY="AllGroups">
      
            
      <CFSET zGroup = "#TRIM(AllGroups.UserGroup)##TRIM(AllGroups.UserGroupType)#">
      <CFSET zTempEndDate = "">
      <CFSET zStartDate = "">
      <CFSET zEndDate = "">
      <CFSET zSubscriberID = "">

      <TR>            

            <td valign=top>                      
                  <input type="Checkbox" name="UserGroup" value="#TRIM(AllGroups.UserGroup)#|*|#TRIM(AllGroups.UserGroupType)#"<CFIF TRIM(GroupList) CONTAINS "#TRIM(AllGroups.UserGroup)##TRIM(AllGroups.UserGroupType)#"> checked</CFIF>>
          </td>         
            
            <td><font face=arial,helvetica size=1>                  
                <a href="##" title="#TRIM(AllGroups.UserGroupName)#" Class="link1">
                      #TRIM(AllGroups.UserGroup)# #TRIM(AllGroups.UserGroupType)#</a>
          </td>             
            
            <td><font face=arial,helvetica size=1>                  
                 #LEFT(RegionCode, 2)#          
               </td>
   
          <td>                  
                  <input type="text" size=1 name="OnGoing#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#" value="<CFIF TRIM(OnGoingList) CONTAINS "#TRIM(AllGroups.UserGroup)##TRIM(AllGroups.UserGroupType)#">Y</CFIF>" Class="textEntry1">
               </td>    
 
             <td>
               <CFLOOP QUERY="Subscribed">
                    <CFIF "#TRIM(zGroup)#" IS "#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#">
                              <CFSET zSubscriberID = "#Subscribed.SubscriptionAccountNumber#">
                              <CFSET zStartDate = DateFormat("#TRIM(Subscribed.StartDate)#","mm/dd/yy")>
                              <CFSET zEndDate = DateFormat("#TRIM(Subscribed.EndDate)#","mm/dd/yy")>
                              <CFSET zTempEndDate = DateFormat("#TRIM(Subscribed.TempEndDate)#","mm/dd/yy")>
                        </CFIF>
                  </CFLOOP>
                  
                  <!--- baseview account number ---><!--- #TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)# --->
                  <input type="text" name="SubscriberAcctNumber#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#" value="#zSubscriberID#" size="7" maxlength="30" Class="textEntry1">
            </td>
            <td>
                  <input type="text" name="StartDate#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#" value="#TRIM(zStartDate)#" size=7 maxlength=30 Class="textEntry1">
            </td>
            <td><input type="text" name="EndDate#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#" value="#TRIM(zEndDate)#" size=7 maxlength=30 Class="textEntry1">  
                     <input type="hidden" name="TempEndDate#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#" value="#TRIM(zTempEndDate)#">
            </td>                  
                  
      </TR>
      
      <CFIF zSubscriberID GT ''>
            <!--- query baseview --->
            <CFQUERY NAME="CA" DATASOURCE="CIRC">
                  SELECT subscription.account, subscription.status, subscription.expiration,
                        publication.publication_name, occupant.company, subscription.notes, publication.publicationcode
                  FROM subscription
                  INNER JOIN publication ON subscription.publicationID = publication.publication_id
                  INNER JOIN occupant ON occupant.name_id = subscription.namedentityid
                  WHERE subscription.account = '#zSubscriberID#'
            </CFQUERY>      
            <!--- <cfdump var="#CA#"> --->
            <CFIF IsDefined("CA.account") AND CA.account GT 0>
                  <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td valign="top">
                              <font face=arial,helvetica size=1>                  
                              #CA.account#
                              <br />#CA.publication_name# <cfif trim(CA.publicationcode) gt "">(#trim(CA.publicationcode)#)</cfif>
                              <br />#CA.company#
                              <br />#CA.notes#
                        </td>
                        <td valign="top">
                                    <font face=arial,helvetica size=1>
                                    Status: #TRIM(CA.status)#
                                    <br /><CFIF #TRIM(CA.status)# EQ 1>Active<CFELSE><font color="red">Inactive</font></CFIF>
                                    </font>
                        </td>
                        <td valign="top">
                                    <font face=arial,helvetica size=1>                  
                                    Exp: #DateFormat(CA.expiration, "mm/dd/yy")#
                                    </font>
                        </td>                  
                  </tr>
            </CFIF>
      </CFIF>
      </CFOUTPUT>            
       
    <TR>
      <td colspan=5 height=50 align=center>
            <input type=submit value="  Save  " Class="button0">
      </td>
      </TR>
            
      </table>  
      

</td>
</TR>
<TR><td height=50>&nbsp;</td></TR>
</TABLE>


</form>
</BODY>
</HTML>
That's how in the form
In the form im using a cfquery output to get usergroup value
Any suggestions or advice gdemaria
So, the problem is these two columns that are doubling the data, right?

{ CALL prMembership       ('112973','WSJ','REGULAR','01/01/10,01/01/20','','','','','y,y','') }

What is the name of the form field for this data:  '01/01/10,01/01/20

AND for this data :  'Y,Y'

We need to see if these fields are set up differently, they should have a name tag with a variable  NAME="XXX#variable#"
form.StartDate = 01/01/10,01/01/20
form.EndDate = doing the same
form.OnGoing = y,y
form.TempEndDate = doing the same
form.SubscriberAcctNumber = doing the same
Sorry I think you meant this

name="OnGoing#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#"
name="StartDate#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#"
name="EndDate#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#"
name="TempEndDate#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#"
name="SubscriberAcctNumber#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#"
So they are all duplicating?

On your form page, view the source and look for the startDate field

 <input type="text" name="StartDate#TRIM(Subscribed.UserGroup)##TRIM(Subscribed.UserGroupType)#"

You will probably see more than one field named  StartdateX where x is some value.    NAME="StartDateX" should be unique, there should only be one of them, the "X" value (whatever it is) needs to be different every time
gdemaria you were right about the name being unique, but I'm still getting an error if the recordcount is more then 19 records that the form submits. The evaluate did work also.

HTTP Status 500 - ROOT CAUSE:

type Exception report

message ROOT CAUSE:

description The server encountered an internal error that prevented it from fulfilling this request.

exception
type Exception report

message ROOT CAUSE:

description The server encountered an internal error that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: ROOT CAUSE:
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
      at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:450)
      at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:119)
      at coldfusion.tagext.io.cache.ehcache.GenericResponseWrapper.sendError(GenericResponseWrapper.java:91)
      at coldfusion.filter.FormScope.parseQueryString(FormScope.java:524)
      at coldfusion.filter.FormScope.parsePostData(FormScope.java:468)
      at coldfusion.filter.FormScope.fillForm(FormScope.java:414)
      at coldfusion.filter.FormScope.setEncoding(FormScope.java:86)
      at coldfusion.runtime.CFPage.SetEncoding(CFPage.java:1194)
      at cfclassic2ecfm557356615._factor21(C:\ColdFusion10\cfusion\wwwroot\WEB-INF\debug\classic.cfm:19)
      at cfclassic2ecfm557356615._factor32(C:\ColdFusion10\cfusion\wwwroot\WEB-INF\debug\classic.cfm:12)
      at cfclassic2ecfm557356615.runPage(C:\ColdFusion10\cfusion\wwwroot\WEB-INF\debug\classic.cfm:1)
      at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:244)
      at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:446)
      at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
      at coldfusion.filter.CfincludeFilter.include(CfincludeFilter.java:33)
      at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:114)
      at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
      at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
      at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58)
      at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
      at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
      at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62)
      at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:151)
      at coldfusion.CfmServlet.service(CfmServlet.java:219)
      at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
      at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:422)
      at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:199)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:722)

      coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:70)
      coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)



note The full stack trace of the root cause is available in the Apache Tomcat/7.0.54 logs.
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I also found the same solution. thanks for you time and effort.