Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I cfset a variable in cfquery

Posted on 2011-09-09
9
Medium Priority
?
326 Views
Last Modified: 2012-05-12
How do I cfset a variable in cfquery so the values will be available in a pull down in a cfgrid

<cfquery name="Get_modality" datasource="xxx">
            SELECT    TDA_UIC, TYPE, ORG_ID_EM
                  FROM      MRE_TARA_MODALITIES
</cfquery>

    <cfset ModalityType = "TYPE">

<cfform>  
<cfgrid>
<cfgridcolumn name="MODALITY"  header="Modality(E)"  width="90" values="#ModalityType#"/>    
</cfgrid>
</cfform>  
0
Comment
Question by:Nigel-SA
  • 5
  • 3
9 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 36515862
Like this:
<cfquery name="Get_modality" datasource="xxx">
            SELECT    TDA_UIC, [TYPE] as ModalityType, ORG_ID_EM
                  FROM      MRE_TARA_MODALITIES
</cfquery>

<cfform>   
<cfgrid name="myGrid" query="Get_modality">
  <cfgridcolumn name="ModalityType"  header="Modality(E)"  width="90" />     
</cfgrid>
</cfform>

Open in new window

0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 36518330
for using the any Cfset variable you set you had to specify a query
0
 

Author Comment

by:Nigel-SA
ID: 36522075
Sorry my fault, I wasn't detailed enough.  Basically I have a main cfgrid query called getICS but wanting to have a pull down within the cfgrid extracting the variable from from another query (Get_modality), so I can insert the value from "Get_modality.Type" into "MODALITY"


<cfquery name="Get_modality" datasource="xxx">
            SELECT    TDA_UIC, TYPE, ORG_ID_EM
            FROM      MRE_TARA_MODALITIES
</cfquery>
   
    <cfset ModalityType = "TYPE">


<cfquery name="getICS" datasource="xxx">
    SELECT   *.*
    FROM MRE_TARA_LIST
</cfquery>

<cfset args = structNew()>
<cfset args.name = "ICS_Grid">
<cfset args.format = "html">
<cfset args.query = "getICS">
<cfset args.stripeRows = true>
<cfset args.selectmode = "edit">
<cfset args.onchange = "cfc:TARA_LIST.editData({cfgridaction},{cfgridrow},{cfgridchanged})">
   
     <cfform>
     
        <cfgrid attributeCollection="#args#">
<cfgridcolumn name="TARA_ID" header="MOD ID" display="no" width="40"/>
<cfgridcolumn name="ORG_ID_EM"  display="no" header="DODAAC"  width="80"/>
<cfgridcolumn name="TDA_UIC"  header="TDA UIC"  display="no" width="80"/>
<cfgridcolumn name="MODALITY"  header="Modality(E)"  width="90" values="#ModalityType#"/>        
<cfgridcolumn name="LOCATION"  header="Location(E)"  width="90"/>
        </cfgrid>
                         
     </cfform>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 63

Expert Comment

by:Zvonko
ID: 36527321
You set the ModalityType like this:
<cfquery name="Get_modality" datasource="xxx">
            SELECT    TDA_UIC, TYPE, ORG_ID_EM
            FROM      MRE_TARA_MODALITIES
</cfquery>
<cfset ModalityType=ArrayNew(1) >
<cfloop query="Get_modality" >   
    <cfset ArrayAppend(ModalityType,TYPE) >
</cfloop>

Open in new window

0
 

Author Comment

by:Nigel-SA
ID: 36528734
Thanks Zvonko, that works - the ModalityType values are loading however I receive the "Complex object types cannot be converted to simple values." error on the line in the cfgrid

  <cfgrid attributeCollection="#args#">
<cfgridcolumn name="MODALITY"  header="Modality(E)"  width="90" values="#ModalityType#"/>  
    </cfgrid>

Full error description:
Complex object types cannot be converted to simple values.  
The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag

Thanks for your help!!
 
0
 

Accepted Solution

by:
Nigel-SA earned 0 total points
ID: 36529209
Zvonko:  I replaced:

<cfset ModalityType=ArrayNew(1) >
<cfloop query="Get_modality" >   
    <cfset ArrayAppend(ModalityType,TYPE) >
</cfloop>

with the following and it worked, (cfgrid remains the same)
<cfset ModalityType = ValueList(Get_modality.TYPE)>



0
 
LVL 63

Expert Comment

by:Zvonko
ID: 36534007
Fine.
0
 

Author Closing Comment

by:Nigel-SA
ID: 37023024
Accidentally found the correct answer
0
 

Author Comment

by:Nigel-SA
ID: 36999123
Please delete question - I found the solution
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question