Solved

Coldfusion LIST <cfif> conditions

Posted on 2008-10-14
4
1,190 Views
Last Modified: 2012-05-05
I have a query which returns a list of items in a field #mainsearch.idParticipants#. I am looping the query and only want to display the 'edit' icon if a certain item is in the list that matches either the employee id #session.empl_id# or the idAuthor #mainsearch.idAuthor#. I can't figure out how to write this conditional code.

This is where I'm having the problem in a nutshell...

<cfloop query="mainsearch">
<tr>
  <td><cfif #session.empl_id# = (IF IT IS IN THIS LIST) '#mainsearch.idParticipants#' OR (#session.empl_id# = '#mainsearch.idAuthor#')>Edit</cfif> </td>
</tr>
</cfloop>

I can't figure out how to write the portion that looks at the list #mainsearch.idParticipants#!

Thanks.
0
Comment
Question by:tport_rti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 22711862
try:
<cfif listfindnocase(mainsearch.idParticipants, session.empl_id)OR listfindnocase(mainsearch.idAuthor, session.empl_id)>Edit</cfif>

assumes the lists are comma-delimited.

but i strongly suggest you re-consider storing lists as field values. it is not a normalized data model and you can run into all sorts of trouble with it later.
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 22711877
oops, i see that idAuthor is not a list, so:

<cfif listfindnocase(mainsearch.idParticipants, session.empl_id) OR (mainsearch.idAuthor eq session.empl_id)>Edit</cfif>
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22711884

try something like this
<cfloop query="mainsearch">
<tr>
  <td><cfif LIstFindNoCase(session.empl_id,mainsearch.idParticipants) gt 0  or LIstFindNoCase (session.empl_id,mainsearch.idAuthor) gt 0>Edit</cfif></td>
</tr>
</cfloop>


0
 

Author Closing Comment

by:tport_rti
ID: 31505916
Thanks much!
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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