Solved

Coldfusion LIST <cfif> conditions

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now