1 Reply Latest reply on Mar 29, 2009 8:35 PM by Newsgroup_User

    How to pass array to cfc?

    slykiwi Level 1

      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?


        • 1. Re: How to pass array to cfc?
          Level 7
          assuming your orderMedia cfc function expects/accepts an argument named
          arrOrder of type Array:

          <cfinvoke component="cfc.media" method="orderMedia"


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

          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"

          Azadi Saryev