Solved

Coldfusion LIST <cfif> conditions

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

829 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