passing structures using cfinvoke.

passing structures using cfinvoke.

Post by SilentBob'secretfusio » Sat, 19 Feb 2005 00:12:43



Quick question.

Can I create a structure in a cfc and then return in?  If so does anyone have a simple example. Thanks.

 
 
 

passing structures using cfinvoke.

Post by Bill Sahla » Sat, 19 Feb 2005 07:15:55


This function returns a structure.  The structure is made up of strings and
a query.

 <cffunction name="cfhttpmydomainphonelist" returntype="struct"
output="true">
   <cfargument name="myuserfname" required="yes"/>
   <cfargument name="myuserlname" required="yes"/>

   <cfhttp url="http://mydomain/IT/IntTools/Phones/PhoneList.txt"
method="get"  name="phonelist"
columns="LastName,FirstName,Extension,Cell,Pager,CubeLocation,DateModified"/>

  <cfquery name="phonelist" dbtype="query">
   SELECT *
   FROM phonelist
   WHERE Lower(LASTNAME) like <cfqueryparam value =
'#lcase(arguments.myuserlname)#' CFSQLType = "CF_SQL_VARCHAR">
   AND Lower(FIRSTNAME) like <cfqueryparam value =
'#lcase(arguments.myuserfname)#%' CFSQLType = "CF_SQL_VARCHAR">
  </cfquery>

  <cfscript>
     results = StructNew();
     StructInsert(results, "statuscode", cfhttp.statuscode);
     StructInsert(results, "query", phonelist);
     StructInsert(results, "recordcount", phonelist.recordcount);
  </cfscript>

   <cfreturn results>
 </cffunction>


Quote:> Quick question.

> Can I create a structure in a cfc and then return in?  If so does anyone
> have a simple example. Thanks.


 
 
 

1. Displaying content via CFINVOKE passing variables via URL

I have been banging my head over why I'm not able to display the resultset from a query as a .CSV file when I pass vars via the URL  .... exportFile.cfm?type='tele'&limit=50 ..etc ...
The strange thing is that if I remove the vars from the URL and just use exportFile.cfm, I have no problem displaying my content! Here's what I have on my CFINVOKE page:

<cfinvoke component="ExportFile" method="getTextFile" returnvariable="result">
<cfinvokeargument name="params" value= #args#>
</cfinvoke>

and then in my component is basically have a DB query, which I then loop over the resultset to generate a .xls CSV file as in the following:

<cfset commaChr = chr(44)>
<cfset newLine = chr(13) & chr(10)>
<cfcontent type=application/msexcel' >
 <cfheader name="Content-Disposition" value="filename=#params.type#.xls">
<cfloop query="getData">
<cfoutput>#ID##commaChr##dayphone##commaChr##firstname##commaChr##lastname##commaChr##street##commaChr##city##commaChr##state##commaChr##zip##commaChr##lender##commaChr##amount##newLine#</cfoutput>
</cfloop>
Any help would be greatly appreciated, other wise I have to go back to using PHP or Perl like I've done before many times without any problems!

TIA

Farid

2. If Statement?

3. Passing structures or user defined data types from COM to coldfusion mx 6.1

4. tweening kernel spacing for fonts?

5. passing form values into structures

6. cut out?

7. Passing structures.

8. Passing Structures to a CFC

9. Using CFinvoke to connect to Web Services

10. Webservic Timeout not working when using cfinvoke

11. Individual CFCs using CFINVOKE

12. using CFCs statically without cfinvoke