Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coldfusion check if function exists

Hello is there a way to check if a function exists in coldfusion. It is throwing an error function is not defined

like image 218
rj tubera Avatar asked Mar 12 '23 12:03

rj tubera


1 Answers

I believe isDefined('functionname') works. So you can do:

<cfif isDefined('functionname')>
    <cfset functionname() />
</cfif>

If it's a potential method of an object named obj for example you can also do:

<cfif structKeyExists(obj,'functionname')>
  <cfset obj.functionname() />
</cfif>

Or

<cfif isDefined('obj.functionname')>
  <cfset obj.functionname() />
</cfif>
like image 136
Leeish Avatar answered Apr 01 '23 05:04

Leeish