Solved

Coldfusion LIST <cfif> conditions

Posted on 2008-10-14
4
1,198 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
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 …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

734 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