Skip to main content
nikos101
Inspiring
October 4, 2011
Question

Coldfusion functions in cfc not accepting single arguments with object type

  • October 4, 2011
  • 4 replies
  • 6387 views

In order to get this to work

I have to put in this line of code <cfargument name="fake" required="true" />

otherwise I get an error:

GeneralDataServerSideService service

Unable to invoke CFC - The ITEM parameter to the updatetbRiskRegister function is required but was not passed in.

<cffunction name="updateUser" output="false" access="remote" returntype="void" >

        <cfargument name="fake" required="true" />

        <cfargument name="item" required="true" />

         <cfquery name="updateItem" datasource="RiskAndCorrectiveActionTracking">

                UPDATE [RiskAndCorrectiveActionTracking].[dbo].[tbUsers]

                   SET [SAMAccountName] = <CFQUERYPARAM cfsqltype="cf_sql_char" VALUE="#item.SAMAccountName#">

                      ,[name] = <CFQUERYPARAM cfsqltype="cf_sql_char" VALUE="#item.name#">

                      ,[email] = <CFQUERYPARAM cfsqltype="cf_sql_char" VALUE="#item.email#">

                      ,[canEditUsers] =  <CFQUERYPARAM cfsqltype="cf_sql_bit" VALUE="#item.canEditUsers#">

                 WHERE id = <CFQUERYPARAM CFSQLTYPE="CF_SQL_INTEGER" VALUE="#item.id#">

        </cfquery>

    </cffunction>

    This topic has been closed for replies.

    4 replies

    BKBK
    Community Expert
    Community Expert
    October 8, 2011

    @Nikos101,

    Does the problem persist after you go to the Caching page of the ColdFusion Administrator and clear cached CFCs?

    BKBK
    Community Expert
    Community Expert
    October 5, 2011

    nikos101 wrote:

    In order to get this to work

    I have to put in this line of code <cfargument name="fake" required="true" />

    otherwise I get an error:

    GeneralDataServerSideService service

    Unable to invoke CFC - The ITEM parameter to the updatetbRiskRegister function is required but was not passed in.

    In my opinion, the cause isn't the way you define the function, but the way you invoke the CFC containing the function. Verify the number and type of the parameters in your invocation code. Could you in fact show us the code that creates the CFC object and invokes the function?

    12Robots
    Participating Frequently
    October 5, 2011

    How could the manner in which you instantiate an object affect the number of arguments it accepts?  He already showed us how he is calling the function. It is a remote method that he is calling from Flex. He is probably not instantiating it at all, unless he is using ColdSpring to create a remote proxy (which there is no indication of).

    Jason

    BKBK
    Community Expert
    Community Expert
    October 5, 2011

    12Robots wrote:

    How could the manner in which you instantiate an object affect the number of arguments it accepts? 

    Not the manner in which you instantiate an object, but the manner in which you invoke the function via the object.

    Inspiring
    October 4, 2011

    The code you are quoting is not the code that is erroring.

    Post the code that's actually erroring (it'll be the code that calls updatetbRiskRegister(), and post the code for updatetbRiskRegister() itself, too).

    --

    Adam

    nikos101
    nikos101Author
    Inspiring
    October 4, 2011

    np

        <cffunction name="updatetbRiskRegister" output="false" access="remote" returntype="void" >

            <cfargument name="item" required="true" />

             <cfquery name="updateItem" datasource="RiskAndCorrectiveActionTracking">

                UPDATE tbRiskRegister SET BusinessUnit = <CFQUERYPARAM cfsqltype=CF_SQL_CHAR VALUE="#item.BusinessUnit#">,

                                 BusinessUnitNumber = <CFQUERYPARAM cfsqltype=CF_SQL_CHAR VALUE="#item.BusinessUnitNumber#">,

                                 SpecificRiskDetail = <CFQUERYPARAM cfsqltype=CF_SQL_CHAR VALUE="#item.SpecificRiskDetail#">,

                         

                                 riskCategoryID = <CFQUERYPARAM cfsqltype=CF_SQL_INTEGER VALUE="#item.riskCategoryID#">

                                 lastUpdated = <CFQUERYPARAM cfsqltype=CF_SQL_INTEGER VALUE="getDate()">

                WHERE id = <CFQUERYPARAM CFSQLTYPE="CF_SQL_INTEGER" VALUE="#item.id#">

            </cfquery>

        </cffunction>

    nikos101
    nikos101Author
    Inspiring
    October 4, 2011

    even if I do this I still get the error

    <cffunction name="updatetbRiskRegister" output="false" access="remote" returntype="void" >
    <cfargument name="item" required="true" type="any" />

    I've been putting up with this for 2 years

    Inspiring
    October 4, 2011

    Did you try adding a type attribute to your cfargument tag?