<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFFUNCTION</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFFUNCTION</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Defines a function that you can call in CFML. Required to define ColdFusion component methods.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion&#160;MX&#160;7: Added the XML value to the returntype attribute.
</p>

<p>
ColdFusion MX: Added this tag.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
Extensibility tags
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">Syntax</span><pre>&lt;cffunction
   name = &quot;methodName&quot;
   returnType = &quot;dataType&quot;
   roles = &quot;securityRoles&quot;
   access = &quot;methodAccess&quot;
description = &quot;function description&quot;
output = &quot;yes&quot; or &quot;no&quot;
   displayName = &quot;name&quot;
   Hint = &quot;hint text&quot;&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
cfargument, cfcomponent, cfinvoke, cfinvokeargument, cfobject, cfproperty, cfreturn
</p>

<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
The cffunction tag can define a function that you call in the same manner as a ColdFusion built-in function. 
</p>

<p>
To define a ColdFusion component (CFC) method, you must use a cffunction tag. 
</p>

<p>
The following example shows cffunction tag attributes for a simple CFC method that returns a ColdFusion Query object.
</p>
<pre>&lt;cffunction
   name=&quot;getEmployees&quot; 
   access=&quot;remote&quot; 
   returnType=&quot;query&quot; 
   hint=&quot;This query returns all records in the employee database. It can
drill-down or narrow the search, based on optional input parameters.&quot;&gt;
</pre>
<p>
For information on using the cffunction tag for ColdFusion components, see Chapter&#160;10, "Building and Using ColdFusion Components" in ColdFusion MX Developer's Guide.
</p>

<p>
If you specify a roles attribute, the function executes only if a user is logged in and belongs to one of the specified roles.
</p>

<p>
If you specify variableName for the returnType attribute, the function must return a string that is in ColdFusion variable name format; that is, the function must return a string that starts with a letter, underscore, or Unicode currency symbol, and consist of letters, numbers, and underscores (_), periods, and Unicode currency symbols, only. ColdFusion does not check whether the value corresponds to an existing ColdFusion variable.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;cfcomponent&gt;
   &lt;cffunction name=&quot;getEmp&quot;&gt;
       &lt;cfquery 
            name=&quot;empQuery&quot; datasource=&quot;ExampleApps&quot; &gt;
            SELECT FIRSTNAME, LASTNAME, EMAIL
            FROM tblEmployees
       &lt;/cfquery&gt;
       &lt;cfreturn empQuery&gt;
   &lt;/cffunction&gt;
   &lt;cffunction name=&quot;getDept&quot;&gt;
      &lt;cfquery 
name=&quot;deptQuery&quot; datasource=&quot;ExampleApps&quot; &gt;
          SELECT *
          FROM tblDepartments
       &lt;/cfquery&gt;
       &lt;cfreturn deptQuery&gt;
   &lt;/cffunction&gt;
&lt;/cfcomponent&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="NAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">NAME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>A string; a component method that is used within the cfcomponent tag.</p>

  </td>
  </tr>
  </table>
</div>
<div id="RETURNTYPE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">RETURNTYPE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required for a web service; Optional, otherwise.</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "&#160;any"


<p>String; a type name; data type of the function return value:</p><ul>

<li>any</li>

<li>array</li>

<li>binary</li>

<li>boolean</li>

<li>date</li>

<li>guid - The argument must be a UUID or GUID of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where each x is a character representing a hexadecimal number (0-9A-F).</li>

<li>numeric</li>

<li>query</li>

<li>string</li>

<li>struct</li>

<li>uuid: the argument must be a ColdFusion UUID of the form xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx where each x is a character representing a hexadecimal number (0-9A-F).</li>

<li>variableName: a string formatted according to ColdFusion variable naming conventions.</li>

<li>void: does not return a value</li>

<li>xml: allows web service functions to return CFML XML objects and XML strings.</li>

<li>a component name: if the type attribute value is not one of the preceding items, ColdFusion treats it as the name of a ColdFusion component. When the function executes, it generates an error if the argument that is passed in is not a CFC with the specified name.</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="ROLES">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ROLES</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "&quot;&quot; (empty)"


<p>A comma-delimited list of ColdFusion security roles that can invoke the method. Only users who are logged in with the specified roles can execute the function. If this attribute is omitted, all users can invoke the method.</p>

  </td>
  </tr>
  </table>
</div>
<div id="ACCESS">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ACCESS</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "public"


<p>The client security context from which the method can be invoked:</p><ul>

<li>private: available only to the component that declares the method and any components that extend the component in which it is defined.</li>

<li>package: available only to the component that declares the method, components that extend the component, or any other components in the package.</li>

<li>public: available to a locally executing page or component method.</li>

<li>remote: available to a locally or remotely executing page or component method, or a remote client through a URL, Flash, or a web service. To publish the function as a web service, this option is required.</li>
</ul>


  </td>
  </tr>
  </table>
</div>
<div id="DESCRIPTION">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DESCRIPTION</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Supplies a short text description of the function.</p>

  </td>
  </tr>
  </table>
</div>
<div id="OUTPUT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">OUTPUT</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "Function body is processed as standard CFML"


<p>Specifies under which conditions the function can generate HTML output.</p><ul>

<li>yes: the entire function body is processed as if it were within a cfoutput tag. Variables names surrounded by number signs (#) are automatically replaced with their values.</li>

<li>no: the function is processed as if it were within a cfsilent tag</li>
</ul>

<p>If you do not specify this attribute, the function body is processed as standard CFML. Any variables must be in cfoutput tags.</p>

  </td>
  </tr>
  </table>
</div>
<div id="DISPLAYNAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DISPLAYNAME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Meaningful only for CFC method parameters. A value to be displayed in parentheses following the function name when using introspection to show information about the CFC.</p>

  </td>
  </tr>
  </table>
</div>
<div id="HINT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">HINT</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Meaningful only for CFC method parameters. Text to be displayed when using introspection to show information about the CFC. The hint attribute value follows the syntax line in the function description.</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
