Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm lost - <cfif> or <cfswitch> 1

Status
Not open for further replies.

JohnShell

Technical User
Aug 29, 2003
35
0
0
US
I do not know which or how to do this. Have lengthy <cfquery> for MS SQL. Have <cfmail> tag to direct results of query to appropriate recipients.

Here's query:

<cfquery datasource="#Application.DSN2#" name="allinone">
SELECT
USER_PIN,
USER_LNM + ', ' + USER_FNM AS FullName,
TEAM_ABBR,
BRNCH_ABBR,
POSN_ABBR,
USER_EMAIL,
(
SELECT E1.USER_EMAIL
FROM USER_VIEW_3 AS E1
WHERE E1.TEAM_ABBR = USER_VIEW_3.TEAM_ABBR
AND E1.POSN_ABBR = 'TL'
) AS TL_EMAIL,
(
SELECT E3.POSN_ABBR
FROM USER_VIEW_3 AS E3
WHERE E3.TEAM_ABBR = USER_VIEW_3.TEAM_ABBR
AND E3.POSN_ABBR = 'TL'
) AS TL_POSITION,
(
SELECT E2.USER_EMAIL
FROM USER_VIEW_3 AS E2
WHERE E2.BRNCH_ABBR = USER_VIEW_3.BRNCH_ABBR
AND E2.POSN_ABBR = 'BC'
) AS BC_EMAIL,
(
SELECT E4.POSN_ABBR
FROM USER_VIEW_3 AS E4
WHERE E4.BRNCH_ABBR = USER_VIEW_3.BRNCH_ABBR
AND E4.POSN_ABBR = 'BC'
) AS BC_POSITION,
(
SELECT E5.POSN_ABBR
FROM USER_VIEW_3 AS E5
WHERE E5.POSN_ABBR = 'DD'
) AS DD_POSITION,
(
SELECT E6.USER_EMAIL
FROM USER_VIEW_3 AS E6
WHERE E6.POSN_ABBR = 'DD'
) AS DD_EMAIL
FROM USER_VIEW_3
WHERE USER_PIN = '#Form.EMPPIN#'
</cfquery>

And here's <cfmail>

<cfif cgi.SERVER_NAME is not "localhost">

<cfmail to="#allinone.TL_EMAIL#"
cc="#allinone.BC_EMAIL#"
from="#session.user.email#"
subject="Request for Additional Work Hours"
type="html">
<html><body>
<font size="+2">#EmpName# submitted a request for
#NoOfHours1# hours of #TypeHrs1# for
#startdate1#.
<br /><br />
Please click the link below to view pending requests.
<br /><br />
<a href=" Requests</a> </font></body></html>
</cfmail>
</cfif>

How do I start? The session user information is captured. The session user could be level 1; 2; 3; 4; 5; or, 6. If the session user is level 1 then for email
to = level 4
cc = level 5
For level 2
to = level 6
no cc
For level 3
to = level 6
no cc
For level 4
to = level 5
no cc
For level 5
to = level 6
no cc

Any suggestions? Thank you - JS
 
What is your concern about CFIF versus CFSWITCH? Without understanding your whole query, it seems like you would either generate the desired results in the sql using CASE

Code:
SELECT   CASE 
         WHEN SomeValue = 1 THEN 'foo@foo.com'
         WHEN SomeValue = 2 THEN 'bar@bar.com'
         ELSE ''
         END AS ToAddress
        , ......
FROM    TableName

... OR pull all of the values. Then use CF code to set the desired addresses for your mail tag.






----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top