Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pass struc to cfc???

Status
Not open for further replies.

marks416

IS-IT--Management
Oct 24, 2007
39
CA
Hi,

I did this but I get error.Please help me .Thanks

test.cfm

<cfscript>

my_obj = CreateObject("component", "testfolder.components.testcfc");

objEmail=StructNew();
objEmail.email="123@msn.com";
objEmail.message ="hello";


my_obj.emailInfo();

</cfscript>


testcfc.cfc

<cfcomponent>
<cffunction name="emailInfo" returntype="boolean" access="remote">
<cfargument name="msgInfo" type="struct" required="true" />

<cfmail to = "#msgInfo.email#" from = "abc@gmail.com"
subject = "hello">
#msgInfo.message#
</cfmail>

<cfreturn true />

</cffunction>
</cfcomponent>

 
You're not actually passing the structure to the component.

Try:

Code:
  my_obj.emailInfo(objEmail);

Should work

Hope this helps!

Tony
 
the following will all do the same thing but I think (argumentCollection=get)works the most consistently... not sure why though...


<cfscript>
get = StructNew()
get.id = 1
get.IsActive = 1
get.isDeleted = 0
rsStruk = getStuff(id=Val(get.ID),IsActive=Val(get.id),IsDeleted=Val(get.isDeleted));
OR
rsStruk = getStuff(argumentCollection=get));
OR
rsStruk = getStuff(get));
</cfscript>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top