Questions tagged [cffunction]

is used in ColdFusion Markup Language (CFML) to create user defined functions.

<cffunction> is used in ColdFusion Markup Language to create user defined functions. The basic syntax is

<cffunction name="myFunc" returntype="string" output="false">

  <cfreturn "Hello, World!">
</cffunction>

Functions may be created as a global function or as apart of an object (cfc). Functions typically include business logic and not presentation logic.

Functions can also be defined in <cfscript> via

string function myFunc() output="false" {
   return "Hello, World!";
}

Resources

https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-f/cffunction.html

37 questions
5
votes
1 answer

Strange behaviour of coldfusion arguments surviving outside function?

I have programmed ColdFusion for over 15 years, but never came across this. Here's a code to replicate the behaviour:
Jörgen Lundgren
  • 273
  • 1
  • 13
4
votes
1 answer

How can I create output from a CFFUNCTION with type "application/json"?

I have a cfc that creates an output string containing JSON. The payload is fine but the person receiving it tells me that the data is coming in as text/html and his program doesn't recognize it as valid because it needs to be application/json. So I…
John P
  • 87
  • 7
4
votes
1 answer

apllication.cfc does not fire any default cffunction? Coldfusion

Can anyone tell me what the problem is? I tried to run some .cfm files but it does not trigger any effect of cffunction except cfcomponent? Am I missing something? Can anyone explain to me?
De De De De
  • 326
  • 3
  • 10
  • 31
4
votes
2 answers

How to check if an argument is received or defined?

I have a function that has these arguments:
Mr_LinDowsMac
  • 2,644
  • 9
  • 56
  • 75
3
votes
2 answers

Using AJAX to get data from a ColdFusion component page, and fill another dropdown with results

I know similar questions have been asked before and answered, but I'm having specific issues with my code. When the dropdown with id="SITE" is changed, I want the dropdown with id="YARD" to fill with yards from that site. Here is my component CFC…
Todd K
  • 73
  • 1
  • 13
3
votes
1 answer

Why can't I pass a form field of type file to a CFFUNCTION using structure syntax?

I'm trying to pass a form field of type "file" to a CFFUNCTION. The argument type is "any". Here is the syntax I am trying to use (pseudocode):
Eric Belair
  • 10,574
  • 13
  • 75
  • 116
3
votes
1 answer

Coldfusion FileUpload function from cfc file not working

I am currently trying to upload a file using a function from a cfc file. I can get the code to work when I just call the on the same page. However, I wanted to learn how to call it from a function in a cfc file. I believe…
Errol Wallace
  • 167
  • 2
  • 13
2
votes
4 answers

Difference between cfparam and cfargument in a coldfusion function?

What's the difference between these two blocks of code, when called right after a cffunction tag:
Luke The Obscure
  • 1,524
  • 2
  • 20
  • 35
2
votes
1 answer

How to return cfdocument pdf file and server to the user in the browser?

I have function that will generate cfdocument pdf file. Then I would like to return the document and server to the browser. Here is example of the function that generates the pdf file.
espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
2
votes
1 answer

How to call cffunction on the cfm page from javascript?

I was wondering if I can call cffunction on my cfm page? I have onClick button that should make a call to the cffunction that is on the same page. Also I have tried to put cfcomponent around my function but I was getting this error: Invalid CFML…
espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
2
votes
1 answer

Handling optional arguments: CFArgument versus isDefined

I have a question about cfargument. If I am sending a parameter when calling a .cfc, is there any benefit to defining it as argument first? Or can I just use…
espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
2
votes
2 answers

Call Javascript function from ColdFusion CFC

I have a ColdFusion function that checks if a record exists in a table, and if it does it returns data for the row found. However, if the record does not exist, I would like to have it make a call to a JavaScript function that I've written and use…
Phil
  • 4,029
  • 9
  • 62
  • 107
2
votes
2 answers

tab character causing ajax coldfusion component to fail, 500 Internal Server Error

I have a form that users will copy and paste text from a word doc. This content may include a tab character. An on-click function handles the form submission using JSMX ajax call to a coldfusion remote function. The form is passed through the ajax…
garyv
  • 187
  • 1
  • 9
1
vote
1 answer

Passing a struct to a function results in nested struct

When I pass a struct to a function that is expecting a struct, the function is nested inside another struct. For example: function getAnswerFromSO(struct question=StructNew()) { …
RHPT
  • 2,560
  • 5
  • 31
  • 43
1
vote
2 answers

In ColdFusion, what is the difference between setting a function to a variable and calling a function in hashtags?

I wrote the following function:
Millhorn
  • 2,953
  • 7
  • 39
  • 77
1
2 3