2 Replies Latest reply: Feb 14, 2014 11:00 AM by BKBK RSS

    Need Help with CFINVOKE

    BYJ_wntrsnt Community Member

      I don't usually get this type of error message when using cfinvoke this way (see below) but this time I keep getting this error no matter how I modify my logic or my codes.

      I've spent a week trying to find what's going on and could not find the answer. Can anyone help please?

      This is the last modification I made with my codes and I still can't get pass this section due to the error message.

      This expression must have a constant value.

      RowIteration.cfc: line 107

      105 : ThisRowNo="#Trim(arguments.ThisRowNo)#"

      106 : Camp="#arguments.Campus#"         

      107 : LYear="#arguments.LYear#">

       

      Here is how my codes, it used to work when I do it this way:

      <!--- I'm looping over an array & validate each required array elements ---> 

      <cfset arr_FileContents = ListToArray(list_w_null2,chr(10), true)> 

      <CFSET var_Count=1>

      <cfloop index="i" array="#arr_FileContents#"> 

        <CFSET PipeLine = Replace(i,chr(9),"|", "ALL")>
         <CFSET PipeLine = replace( PipeLine, "||", "| |", "all" )>
         <CFSET PipeLine = replace( PipeLine, "||", "| |", "all" )>
         <CFSET PipeLine = reReplace( PipeLine, "\|$", "| ", "all" )>
         <CFSET arr_ThisRow = ListToArray(PipeLine, '|', true)
      >

        <cfinvoke component="MyComp.PComp.CheckRow" method="ValidateRow"                                                                                 

                                                                         arr="#arr_ThisRow#"                                                                                                              
                                                                         Camp="#Trim(Institution)#"
                                                                         LYear="#Trim(load_year)#"
                                                                         ThisRowNo="#Trim(var_Count)#">   

       

        <CFSET var_Count=#var_Count#+1>

       

      </cfloop>

       

       

       

      <!--- In my cfc --->   

      <CFCOMPONENT> 

       

            <CFFUNCTION name="ValidateRow">            

               <cfargument name="arr" type="Array" required="TRUE"> 

               <cfargument name="Camp" type="String" required="TRUE"> 

               <cfargument name="LYear" type="String" required="TRUE">        

               <cfargument name="ThisRowNo" type="Numeric" required="TRUE">

       

                 <cfset st_ReqFields=StructNew()>                 

                 <cfset st_ReqFields["NameType"]="#Trim(arr[6])#">    

                 <cfset st_ReqFields["PtLN"]="#Trim(arr[7])#">

                 <cfset st_ReqFields["PtFN"]="#Trim(arr[8])#">    

                 <cfset st_ReqFields["PtPrefix"]="#Trim(arr[10])#">

                 <cfset st_ReqFields["Sex"]="#Trim(arr[13])#">    

                 <cfset st_ReqFields["PAddr"]="#Trim(arr[19])#">

              <CFIF arr[19] EQ "H">   

                <cfset st_ReqFields["HAddr1"]="#Trim(arr[20])#">

                <cfset st_ReqFields["HCity"]="#Trim(arr[23])#"> 

                <cfset st_ReqFields["HState"]="#Trim(arr[24])#">       

                <cfset st_ReqFields["HZip"]="#Trim(arr[25])#">

                <cfset st_ReqFields["HCountry"]="#Trim(arr[26])#">      

                <cfset st_ReqFields["HPhone"]="#Trim(arr[28])#">

                <cfset st_ReqFields["HUnlistedFlag"]="#Trim(arr[29])#">   

              <CFELSE><!--- arr[19] IS "B" --->

               <cfset st_ReqFields["BAddr1"]="#Trim(arr[33])#">

               <cfset st_ReqFields["BCity"]="#Trim(arr[36])#">

               <cfset st_ReqFields["BState"]="#Trim(arr[37])#">     

               <cfset st_ReqFields["BZip"]="#Trim(arr[38])#">

               <cfset st_ReqFields["BCountry"]="#Trim(arr[39])#">      

               <cfset st_ReqFields["BPhone"]="#Trim(arr[41])#">

               <cfset st_ReqFields["BUnlistedFlag"]="#Trim(arr[42])#">    

             </CFIF>

       

           <!--- I can't get pass this cfinvoke! I used to be able to invoke other method within cfc and my other apps are still working when I'm doing

                  it this way. I have never gotten this type of error   --->

       

            <CFINVOKE component="MyComp.PComp.ValFields" method="CheckReqFields"

                                                                        st_ReqFields="#st_ReqFields#"

                                                                        ThisParent="1"                                                           

                                                                        ThisRowNo="#Trim(arguments.ThisRowNo)#"

                                                                        Camp="#arguments.Camp#"         

                                                                        LYear="#arguments.LYear#">

       

       

      </'CFCOMPONENT>

       

      <!--- Other component --->

      <CFCOMPONENT><!--- ValFields --->

          

          <CFFUNCTION name="CheckReqFields">

            etc...

          </CFFUNCTION>

       

      </CFCOMPONENT> 

        • 1. Re: Need Help with CFINVOKE
          Fernis Community Member

          I would start debugging from the down up for any syntax errors in the ColdFusion code, and then check also if the functions may return an error on certain arguments.

           

          If you invoke a component function which further invokes another function, and the inner function fails, ColdFusion error report may not always return you the correct failure point and the line of code. If the inner function fails, the outer function cannot execute either.

           

          Start invoking your checkReqFields() directly from some template to debug it first.

           

          Check that none of your argument values are objects (i.e. arrays, strcture, query) by accident.

          • 2. Re: Need Help with CFINVOKE
            BKBK Community Member

            I missed some relevant information: the code for the signature and arguments of checkReqFields. Also, I got a little confused between page-local and method-local variables. However, nothing jumps out as an obvious source of error. My suggestions are in bold.

             

            <cfset arr_FileContents = ListToArray(list_w_null2,chr(10), true)>

            <CFSET var_Count=1>

            <cfloop index="i" array="#arr_FileContents#">

              <CFSET PipeLine = Replace(i,chr(9),"|", "ALL")>

               <CFSET PipeLine = replace( PipeLine, "||", "| |", "all" )>

               <CFSET PipeLine = replace( PipeLine, "||", "| |", "all" )>

               <CFSET PipeLine = reReplace( PipeLine, "\|$", "| ", "all" )>

               <CFSET arr_ThisRow = ListToArray(PipeLine, '|', true)?>

             

            <cfinvoke component="MyComp.PComp.CheckRow" method="ValidateRow"                                                                                  

                                                                               arr="#arr_ThisRow#"                                                                                                              

                                                                               Camp="#Trim(Institution)#"

                                                                               LYear="#Trim(load_year)#"

                                                                               ThisRowNo="#Trim(var_Count)#">  

              <CFSET var_Count=var_Count+1>

            </cfloop>

             

            <!--- In my cfc --->  

             

            <CFCOMPONENT>

                  <CFFUNCTION name="ValidateRow">?           

                     <cfargument name="arr" type="Array" required="TRUE">

                     <cfargument name="Camp" type="String" required="TRUE">

                     <cfargument name="LYear" type="String" required="TRUE">       

                     <cfargument name="ThisRowNo" type="Numeric" required="TRUE">

             

                      <cfset var st_ReqFields=StructNew()> 

                       <cfset var local_arr=arrayNew(1)>

                       <cfset local_arr=arguments.arr> 

             

                       <cfset st_ReqFields["NameType"]="#Trim(local_arr[6])#">   

                       <cfset st_ReqFields["PtLN"]="#Trim(local_arr[7])#">

                       <cfset st_ReqFields["PtFN"]="#Trim(local_arr[8])#">   

                       <cfset st_ReqFields["PtPrefix"]="#Trim(local_arr[10])#">

                       <cfset st_ReqFields["Sex"]="#Trim(local_arr[13])#">   

                       <cfset st_ReqFields["PAddr"]="#Trim(local_arr[19])#">

                   <CFIF local_arr[19] EQ "H">  

                      <cfset st_ReqFields["HAddr1"]="#Trim(local_arr[20])#">

                      <cfset st_ReqFields["HCity"]="#Trim(local_arr[23])#">

                      <cfset st_ReqFields["HState"]="#Trim(local_arr[24])#">      

                      <cfset st_ReqFields["HZip"]="#Trim(local_arr[25])#">

                      <cfset st_ReqFields["HCountry"]="#Trim(local_arr[26])#">     

                      <cfset st_ReqFields["HPhone"]="#Trim(local_arr[28])#">

                      <cfset st_ReqFields["HUnlistedFlag"]="#Trim(local_arr[29])#">  

                    <CFELSE><!--- local_arr[19] IS "B" --->

                     <cfset st_ReqFields["BAddr1"]="#Trim(local_arr[33])#">

                     <cfset st_ReqFields["BCity"]="#Trim(local_arr[36])#">

                     <cfset st_ReqFields["BState"]="#Trim(local_arr[37])#">    

                     <cfset st_ReqFields["BZip"]="#Trim(local_arr[38])#">

                     <cfset st_ReqFields["BCountry"]="#Trim(local_arr[39])#">     

                     <cfset st_ReqFields["BPhone"]="#Trim(local_arr[41])#">

                     <cfset st_ReqFields["BUnlistedFlag"]="#Trim(local_arr[42])#"> 

                   </CFIF>

             

                  <CFINVOKE component="MyComp.PComp.ValFields" method="CheckReqFields"

                                        st_ReqFields="#st_ReqFields#"

                                        ThisParent="1"                                                           

                                        ThisRowNo="#Trim(arguments.ThisRowNo)#"

                                        Camp="#arguments.Camp#"        

                                        LYear="#arguments.LYear#">

             

            </CFFUNCTION>

            </CFCOMPONENT>

             

            <!--- Other component --->

            <CFCOMPONENT><!--- ValFields --->

             

                <CFFUNCTION name="CheckReqFields">

                <cfargument name="st_ReqFields" type="struct" required="TRUE">

                <cfargument name="ThisParent" type="Numeric" required="TRUE">

                <cfargument name="ThisRowNo" type="Numeric" required="TRUE">

                <cfargument name="Camp" type="String" required="TRUE">

                <cfargument name="LYear" type="String" required="TRUE">      

             

                  etc...

                </CFFUNCTION>

             

            </CFCOMPONENT>