Skip to main content
Known Participant
November 11, 2008
Question

CFARGUMENT help!

  • November 11, 2008
  • 2 replies
  • 434 views
I'd like to use the existing function within a component. Since that function is exactly what I need it would be great if I don't have to rewrite the same query again and again.
The problem is, that existing CFFUNCTION accept 3 arguments, while my calling page only passing 2 parameters. See the code below:

This is the existing cffunction that I need to use:

<CFFUNCTION Name="getCOF" >
<cfargument name="Type" required="true">
<cfargument name="Client" required="true">
<cfargument name="FiscalYear" required="true">

<cfquery name="getInfo" datasource="#Application.datasource#">
select id ,ins,year,seq,type,name,title
from cfname
where type = <cfqueryparam cfsqltype="CF_SQL_CHAR" value="#Type#" />
and ins = <cfqueryparam cfsqltype="CF_SQL_CHAR" value="#Client#" />
and year=<cfqueryparam cfsqltype="CF_SQL_CHAR" value="#FiscalYear#" />
</cfquery>

<cfreturn getInfo>
</CFFUNCTION>

This is how I call this function within a component:

<cfinvoke component="com.COF" method="getCOF"
Type="U" Client="#u.group#" returnvariable="q_FNInfo">

So, I'm not passing Fiscal Year to the function that is ecpecting argument for FiscalYear.
This function is used by other page where the calling page passing Type, Client and FiscalYear

If I do not pass FiscalYear to this Function I will get error saying the function has an argument called FiscalYear
that is set as required but not passed.
How can I still use the same function when I only passing 2 parameters instead of three, can it be done?
I'm on CF8,Sybase and Unix
Please help, thanks.






This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
November 12, 2008
How can I still use the same function when I only passing 2 parameters instead of three, can it be done?
No. The attribute "required" means you must supply an argument. It is quite clear why you have to. The function requires all 3 arguments. The query uses them as filters. So, my question is, why would you want to pass only 2 arguments?




Inspiring
November 11, 2008
Either make the fiscal year argument optional and do something to generate a default value in your function,

or,

create a fiscal year value in the calling function and pass it as an argument.