{"id":243,"date":"2011-06-04T00:15:36","date_gmt":"2011-06-04T00:15:36","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=243"},"modified":"2011-06-04T00:15:36","modified_gmt":"2011-06-04T00:15:36","slug":"coldfusion-function-cfc-dynamic-arguments","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/coldfusion-function-cfc-dynamic-arguments\/","title":{"rendered":"ColdFusion function \/ CFC &#8211; dynamic arguments"},"content":{"rendered":"<p>Passing a dynamic number of arguments to a ColdFusion function is possible, but the method isn&#39;t obvious. ColdFusion provides the <a href=\"http:\/\/livedocs.adobe.com\/coldfusion\/8\/buildingComponents_28.html\">argumentCollection<\/a> attribute, which assists the <strong>passing<\/strong> dynamic arguments, but how do we access these argument names dynamically within the function?<\/p>\n<p>The answer lies in the fact that the arguments object is a structure, whose keys are the arguments passed to the function.<\/p>\n<p>The example below may help explain:<\/p>\n<p><code>&lt;cffunction name=&quot;myfunction&quot; access=&quot;remote&quot; output=&quot;true&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;cfdump var=&quot;#arguments#&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;cfoutput&gt;#arguments.param1#&lt;\/cfoutput&gt;<br \/>\n\t&lt;\/cffunction&gt;<br \/>\n\t<\/code><\/p>\n<p>Test the output with a GET request:<\/p>\n<p><code>http:\/\/mysite.com\/components\/mycfc.cfc?method=myfunction&amp;ReturnFormat=json&amp;param1=test<br \/>\n\t<\/code><\/p>\n<p>\n\tNotice that we haven&#39;t defined any arguments using &lt;cfargument&gt;. Yet, we are able to access these by referencing the arguments structure&#39;s keys.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Passing a dynamic number of arguments to a ColdFusion function is possible, but the method isn&#39;t obvious. ColdFusion provides the argumentCollection attribute, which assists the&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[34],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/243"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=243"}],"version-history":[{"count":1,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":244,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/243\/revisions\/244"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}