Skip to main content
Participating Frequently
August 3, 2011
Question

The 'argumentname' argument passed to the 'Methodename 'function is not of type 'Dto name'

  • August 3, 2011
  • 2 replies
  • 931 views

Hi, there!

Sr for that question, because it should be pretty easy to answer, but i'm totally new to coldfusion

and googled for about an hour now. I have a orm DTO.cfc:

<cfcomponent entityname="testDTO" persistent="true" table="test"  schema="informix" output="false">
    <!---- properties ----> 
</cfcomponent>

and have a service Methode in test.cfc

    <!---- Add test---->
    <cffunction name="createTest" returntype="testDTO" access="remote">
        <cfargument name="item" type="testDTO" required="true" />
        <!---- Auto-generated method
          Insert a new record in test---->
        <cfset entitysave(item) />
        <!---- return created item ---->
        <cfreturn item/>
    </cffunction>

i try to call via the the <cfInvoke>-Tag

<cfset lieferant = entityNew('test')>

<cfinvoke
    component="#request.componentbase#.test"
    method="createTest"
    item="#test#"
    returnvariable="test">

but the error

'The ITEM argument passed to the createLieferant function is not of type testDTO.'
appears on function call. I just can't find a way to tell cf that lieferant is of type testDTO.
When i type the methodes parameter to struct the methode call works well.

Thanks for your help in advance!
Florian
    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    August 4, 2011

    From the example you've given, the type is DTO(name of CFC), not testDTO.

    glamorous_Wonder6C1C
    Inspiring
    August 3, 2011

    Hi NewFlo,

    Though i have not worked with ORM, but it seems error is not related to ORM. It is simply type mismatch.

    The value you are passing to the function "createTest" is not a object of "testDTO".

    I think the problem is your calling, you are providing wrong value for "item" which should be object of "testDTO".

    Thanks

    Saurav

    NewFloAuthor
    Participating Frequently
    August 3, 2011

    Thx for your reply.

    But you got me wrong on the problem i have.

    I understand what the error wants to tell me, but i don't

    know why the error happens.

    I create a variable using the entity Method, passing the class name testDTO

    <cfset test = entitynew("testDTO")>

    In my opinion the should result in the variable set to type testDTO.

    Wenn i dump the variable it also shows this class name as header of the structure.

    But when i try to pass the var to the methode the error appears.

    I also tried the createObject-Methode resulting in the same error.

    all the best,

    florian

    Owainnorth
    Inspiring
    August 3, 2011

    I'm assuming your extract there isn't quite right:

    <cfset lieferant = entityNew('test')>

    <cfinvoke
        component="#request.componentbase#.test"
        method="createTest"
        item="#test#"
        returnvariable="test">

    You're doing item="#test#", surely this should be item="#lieferant#"?

    In which case, you've done  <cfset lieferant = entityNew('test')>, which is of type "test", not "testDTO"?

    If you're still having trouble, remove the item="" attribute from CFINVOKE and use CFINVOKEARGUMENTs instead.