Skip to main content
March 30, 2009
Question

How to pass array to cfc?

  • March 30, 2009
  • 1 reply
  • 1600 views
Hi,

Can anyone please help explain how to pass an array to a cfc?

I have a comma delimitered numeric string called "orderedMedia".

I create a new array:
<cfset orderArrayList=ArrayNew(1)>

I turn that string into an array:
<cfset orderArrayList = ListToArray(#orderedMedia#)>

I dump my results and can see the array just fine, but I cant figure out how to pass the array to my cfc. I just get the error message "You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members."

Here is what I was attempted:
<cfinvoke component="cfc.media" method="orderMedia" argumentcollection="#orderArrayList#">

Any ideas please?

Cheers,

Aaron
This topic has been closed for replies.

1 reply

Inspiring
March 30, 2009
assuming your orderMedia cfc function expects/accepts an argument named
arrOrder of type Array:

<cfinvoke component="cfc.media" method="orderMedia"
arrOrder="#ListToArray(orderedMedia)#">

or

<cfinvoke component="cfc.media" method="orderMedia">
<cfinvokeargument name="arrOrder" value="#ListToArray(orderedMedia)#">
</cfinvoke>

or, if you want to use ArgumentCollection attribute, then you need to
first create a structure and populate it with member(s) and then pass it
to this argument:

<cfset args = structnew()>
<cfset args.arrOrder = ListToArray(orderedMedia)>
<cfinvoke component="cfc.media" method="orderMedia"
argumentcollection="#args#">

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/