Skip to main content
Inspiring
October 13, 2008
Question

Simple cfinvoke not working

  • October 13, 2008
  • 2 replies
  • 545 views
I have a page calling a pretty basic function of my CFC. Here's the code of the calling page:

<cfscript>
session.stCampaignData=structNew();
session.stCampaignData.campaignName="my name";
session.stCampaignData.campaignDesc="description";
</cfscript>

<cfinvoke component="#application.pathToMyCFC#" method="addCampaign" argumentcollection="#session.stCampaignData#">

Here's the function code:
<cffunction name="addCampaign" hint="Adds a Campaign to the system." access="public" returntype="void" output="false">
<cfargument name="stCampaignData" type="struct" required="true" />
...
</cffunction>

But no matter what, this function bombs. It's as if the argument never makes it:
The STCAMPAIGNDATA parameter to the addCampaign function is required but was not passed in.

If I set the output to true, in the function call, I can dump the session.stCampaignData structure.

Am I overlooking something??

TIA

    This topic has been closed for replies.

    2 replies

    Inspiring
    October 13, 2008
    > But no matter what, this function bombs. It's as if the
    > argument never makes it:
    > argumentcollection="#session.stCampaignData#

    I think that syntax will pass in the structure contents as arguments. Not the structure object itself. So in other words, the function call looks something like this:

    addCampaign( campaignName= "myName", campaignDesc="description");

    As opposed to:

    addCampaign( argumentcollection=session ); ... or ...
    addCampaign( stCampaignData=session.stCampaignData);
    Inspiring
    October 13, 2008
    > <cfinvoke component="#application.pathToMyCFC#" method="addCampaign"
    > argumentcollection="#session.stCampaignData#">

    > <cfargument name="stCampaignData" type="struct" required="true" />

    If stCampaignData is a single argument, then you want to pass it in by
    name, eg:

    <cfinvoke component="#application.pathToMyCFC#" method="addCampaign"
    stCampaignData="#session.stCampaignData#">

    ArgumentCollection is for passing in a bunch of arguments as a single
    struct.

    --
    Adam