Link to home
Start Free TrialLog in
Avatar of Kofi Boateng
Kofi Boateng

asked on

Status: 500, The value returned from the get_score function is not of type query

I am new to cfajaxproxy calls to cfcomponent. I wrote this code but having challenges with this error -- uncaught SyntaxError: parseJSON and then I modified it the code and error messaged changed to "Status: 500, The value returned from the get_score function is not of type query."  Can someone help with what the error might be? When it comes to the cffunction whenever I change the type attribute from ="any" to "number" for one of the attributes, I get this error "The PROPERTY_ID argument passed to the get_score function is not of type numeric.If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible."

This is the cfc file or ColdFusion component:


<cfcomponent>
    <cffunction name="get_score" output="false" access="remote" returnformat="json" returntype="query" >
        <cfargument name="begin_date" required="true" type="any" >
        <cfargument name="end_date" required="true" type="any" >
        <cfargument name="property_id" required="true" type="numeric" default="0" >

        <cfquery name="getScore" datasource="#client.datasource#">
            SELECT top 1 t1.Property_Id,  t1.Inspection_Id,  t1.Inspection_Date AS inspection_date,  t1.Inspection_Score as inspection_score,  t1.Inspection_HS_Score as inspection_hs_score
                , '' AS physical_insp_rating_code, '' AS  physical_insp_reviewer_code
            FROM vw_physical_inspection_rpt t1
            WHERE t1.Property_Id = #arguments.property_id#
            AND t1.Inspection_Date  BETWEEN '#arguments.begin_date#' AND '#arguments.end_date#'
            ORDER BY t1.Inspection_Date DESC
        </cfquery>
    <cfreturn get_score />
</cffunction>
<!--- ////////////////////////////////////////////////////////////////////////////////////// --->
<cffunction name="get_Review_score" output="false"  access="remote" returnformat="json">
        <cfargument name="begin_date" required="true" type="any" >
        <cfargument name="end_date" required="true" type="any" >
        <cfargument name="property_id" required="true" type="any" >
        <cfquery name="getReviewScore" datasource="#client.datasource#">
            SELECT top 1 *
            FROM management_r
            WHERE property_id = #arguments.property_id#
            AND overall_rating_code <> '00'
            AND conducted_date BETWEEN '#arguments.begin_date#' AND '#arguments.end_date#'
            ORDER BY conducted_date DESC
        </cfquery>
        <cfreturn getReviewScore />
</cffunction>

Here is the Javascript file:


<script lang="Javascript" type="text/javascript">

    var end_date = document.getElementById('end_date').value;
    var begin_date = document.getElementById('begin_date').value;
    var property_id = #Val(client.property_id)#;

    // Use an asynchronous call to get the scores for the HUD inspection score from the ColdFusion server.
            var get_score = function(){
                // create an instance of the proxy.  
                var s = new proxyScore();
                // Setting a callback handler for the proxy automatically makes the proxy's calls asynchronous.
                s.setCallbackHandler(populateInspectionScores);
                s.setErrorHandler(myErrorHandler);
            // The proxy get_score function represents the CFC get_score function.
                s.setQueryFormat('column');
                s.get_score(begin_date,end_date,property_id);
                s.get_Review_score(begin_date,end_date,property_id);
            }

    // Callback function to display the results of the get_score
    var populateInspectionScores = function(response)
            {
                var iscores = response.DATA;
                document.getElementById('reac_inspection_number').value = iscores.INSPECTION_ID;
                document.getElementById('physical_inspection_date').value = iscores.INSPECTION_DATE;
                document.getElementById('reac_inspection_score').value = iscores.INSPECTION_SCORE;
                document.getElementById('reac_inspection_hs_score').value = iscores.INSPECTION_HS_SCORE;            
            }

  // Error handler for the asynchronous functions.
            var myErrorHandler = function(statusCode, statusMsg)
            {
                alert('Status: ' + statusCode + ', ' + statusMsg);
            }

</script>

And then the HTML or CFML code:


<cfinput name="end_date" type="datefield" validate="date"  message="TO DATE must be a valid date" size="12" value="" id="end_date" onblur="get_score();">
SOLUTION
Avatar of _agx_
_agx_
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
ASKER CERTIFIED SOLUTION
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