[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1148
  • Last Modified:

Nested IIF() functions

I get an "Undefined variable" error when ColdFusion tries to evaluate this nested iif() expression:

#iif(scheduled_to_run IS "Y", de("Yes"), iif(scheduled_to_run IS "N", de("No"), scheduled_to_run))#

I've had to settle for this expression that works:

#iif(scheduled_to_run IS "Y", de("Yes"), de("No"))#

...but it doesn't display the value of scheduled_to_run if it as an unexpected value (neither "N" or "Y").

I don't want to use <cfif>.  I'm just stuborn.

0
CarlsonCo
Asked:
CarlsonCo
  • 2
1 Solution
 
jyokumCommented:
an if statement is going to be better than using iif

I realize you said you don't want to use <cfif> but here goes anyways...

<cfscript>
if(scheduled_to_run eq 'Y') result = 'Yes';
elseif(schedule_to_run eq 'N') result = 'No';
else result = scheduled_to_run;
</cfscript>

<cfoutput>#result#</cfoutput>
0
 
CarlsonCoAuthor Commented:
I'm more interested in finding out why the ColdFusion expression evaluator is puking on this.
0
 
danrosenthalCommented:
Interesting problem. Not exactly sure why, but having multiple DE() works:

#iif(scheduled_to_run IS "Y", de("Yes"), iif(scheduled_to_run IS "N", de(de("No")), de(de(scheduled_to_run))))#

Just for curiousity I went another level in and found I needed 3 DE() statements to get the values out:
#iif(scheduled_to_run IS "Y", de("Yes"), iif(scheduled_to_run IS "N", de(de("No")), iif(scheduled_to_run IS "M",de(de(de("Maybe"))),de(de(de(scheduled_to_run))))))#


Very odd.
0
 
CarlsonCoAuthor Commented:
Dan the man,
LOL...that's too hilarious!  I knew there was a way around their funky expression evaluator.

It's definately not C style expressions.  But I understand their expression evaluator much better now.

Thanks a lot!
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now