Skip to main content
Participant
February 3, 2008
Question

The Argument passed to a function is not of type numeric

  • February 3, 2008
  • 2 replies
  • 648 views
Hi,

Can someone please tell me what's wrong with this code and it's giving me an error "The argument INTPREVAGREEMENTID passed to function getPreviousAgreementID() is not of type numeric.?
Here's the Cffunction:

<cffunction name="getPreviousAgreementID" access="public" returntype="numeric" output="false">
<cfargument name="intPrevAgreementID" type="numeric" required="yes">

<cfquery name="getPrev" datasource="#application.DSN#">
SELECT TOP 1 Agreement_ID
FROM Agreements
WHERE Agreement_ID < <cfqueryparam value="#arguments.intPrevAgreementID#" cfsqltype="cf_sql_numeric">
ORDER BY Agreement_ID DESC
</cfquery>

<cfif getPrev.recordcount EQ 0>
<cfset prevAgreement= -1>
<cfelse>
<cfset prevAgreement = getPrev.Agreement_ID>
</cfif>

<cfreturn prevAgreement>
</cffunction>

----
The code calling this cffunction,

<cfset previousAgreement = oAgreement.getPreviousAgreementID(tempAgreementId)>
<cfif len(trim(previousAgreement)) NEQ 0>
<img src="images/iconprevious.gif" width="22" height="16" alt="Previous Agreement" onClick="btnSubmit('salesrep_Agreement.cfm?record=#previousAgreement#')" class="mouse">
</cfif>

-----tempAgreementId -----
<cfif url.record NEQ -1>
<cfset tempAgreementId = url.record>
</cfif>

url.record is set initially to -1. I Also tried using 0 just for testing purposes and still gave the same error.

Please help!
Thanks.
    This topic has been closed for replies.

    2 replies

    Inspiring
    February 3, 2008
    Output the value of tempAgreementId immediately before you call the
    function. I don't think its value is what you think it is.

    Dan: "integer" ia not one of the default argument types for <cfargument>.
    This means CF will look around for a CFC called "integer", and require the
    argument to be an instance of that CFC. Almost certainly *not* what the OP
    wants to have happen.

    --
    Adam
    meeyawAuthor
    Participant
    February 3, 2008
    Thanks a lot! I was able to find what's wrong. I was calling the function without the enclosed ().
    &lt;cfparam name=&quot;tempAgreementId&quot; default=&quot;#oAgreement.getNewAgreementId#&quot;&gt;

    correct syntax:
    &lt;cfparam name=&quot;tempAgreementId&quot; default=&quot;#oAgreement.getNewAgreementId()#&quot;&gt;
    Inspiring
    February 3, 2008
    Change numeric to integer.