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."
<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.dataso urce#">
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_cod e
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.dataso urce#">
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>
<script lang="Javascript" type="text/javascript">
var end_date = document.getElementById('e nd_date'). value;
var begin_date = document.getElementById('b egin_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(popul ateInspect ionScores) ;
s.setErrorHandler(myErrorH andler);
// The proxy get_score function represents the CFC get_score function.
s.setQueryFormat('column') ;
s.get_score(begin_date,end _date,prop erty_id);
s.get_Review_score(begin_d ate,end_da te,propert y_id);
}
// Callback function to display the results of the get_score
var populateInspectionScores = function(response)
{
var iscores = response.DATA;
document.getElementById('r eac_inspec tion_numbe r').value = iscores.INSPECTION_ID;
document.getElementById('p hysical_in spection_d ate').valu e = iscores.INSPECTION_DATE;
document.getElementById('r eac_inspec tion_score ').value = iscores.INSPECTION_SCORE;
document.getElementById('r eac_inspec tion_hs_sc ore').valu e = iscores.INSPECTION_HS_SCOR E;
}
// Error handler for the asynchronous functions.
var myErrorHandler = function(statusCode, statusMsg)
{
alert('Status: ' + statusCode + ', ' + statusMsg);
}
</script>
<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();">
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.dataso
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,
FROM vw_physical_inspection_rpt
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.dataso
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('e
var begin_date = document.getElementById('b
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(popul
s.setErrorHandler(myErrorH
// The proxy get_score function represents the CFC get_score function.
s.setQueryFormat('column')
s.get_score(begin_date,end
s.get_Review_score(begin_d
}
// Callback function to display the results of the get_score
var populateInspectionScores = function(response)
{
var iscores = response.DATA;
document.getElementById('r
document.getElementById('p
document.getElementById('r
document.getElementById('r
}
// 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.