1

I have a single cffunction which returns multiple queries. I'm using 'struct' as my returntype. My question is, how do I use function returns in multiple cfselects. I can get the cfdump to work, but not sure what to put in

cfc
 <cffunction name="cfcName" access="remote" returntype="struct">
  <cfset var myStruct=StructNew()>

  <!---Query1---->
  <cfquery name="Query1" datasource="dsn">
   SELECT DISTINCT Col1
   FROM Table1
   ORDER BY Col1 
  </cfquery>

  <!---Query2---->
  <cfquery name="Query2" datasource="dsn">
   SELECT DISTINCT Col2
   FROM table2
   ORDER BY Col2 
  </cfquery>

  <cfset myStruct.Query1= Query1>
  <cfset myStruct.Query2= Query2>

  <cfreturn myStruct>
</cffunction>

<cfinvoke
  component="CMPT"
  method="cfcName"
  returnvariable="Return_cfcName">
</cfinvoke>


cfm,
(Query 1 returns should diplay in this cfselect)
<cfselect name="Select1" required="no" query="?" value="?" display="?" queryPosition="below">
        <option value="">ALL</option>
</cfselect>

(Query 2 returns should diplay in this cfselect)
<cfselect name="Select2" required="no" query="?" value="?" display="?" queryPosition="below">
        <option value="">ALL</option>
</cfselect>

Any help is appreciated, thanks in advance.

1 Answer 1

1

This should do the trick...

<cfselect name="Select1" required="no" query="Return_cfcName.Query1" value="Col1" display="Col1" queryPosition="below">
        <option value="">ALL</option>
</cfselect>


<cfselect name="Select2" required="no" query="Return_cfcName.Query2" value="Col2" display="Col2" queryPosition="below">
        <option value="">ALL</option>
</cfselect>
Sign up to request clarification or add additional context in comments.

1 Comment

you are a star, that works. I had <.....query='Return_cfcName.Query1' value='Return_cfcName.Col1' display='Return_cfcName.Col1'>. Changed it like you've mentioned, now it works like a charm. Thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.