• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Entirly dynamic IF conditions

Guest
Feb 19, 2010 Feb 19, 2010

Copy link to clipboard

Copied

Hey All,

I am doing something a little strange. Basically I have a database table with some coldfusion If statments. Things like

"age GT 18" or

"name eq 'frank'"

etc. Basically it's a dynamic rule engine. Allows my users to place triggers in an app. Question is, how do I evalulate those conditions. I pull them from the database, loop over the query, but I can't actually get CF to parse the contructed IF statment. For example...

<cfset YearsOld = 67>

<cfquery name="GetConditions" datasource="webserver">
     Select *
     From SignUpFormAdditionalActions
     Where Active = 1
</cfquery>

<cfoutput>
     <cfloop query="GetConditions">
          <cfif GetConditions.Condition>
               Met #GetConditions.Name#. #GetConditions.Content#<br />
          </cfif>
          
     </cfloop>
</cfoutput>

And here is what my database looks like

DBSample.PNG

I know this should be easy, I'm just kinda having a brain fart. Thanks!

TOPICS
Advanced techniques

Views

430

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 19, 2010 Feb 19, 2010

Copy link to clipboard

Copied

Ah I figured it out. Using DE and evaluate.

<cfquery name="GetConditions" datasource="webserver">
     Select *
     From SignUpFormAdditionalActions
     Where Active = 1
</cfquery>

<cfoutput>
     <cfset YearsOld = 67>
     <cfloop query="GetConditions">
          <cfset result = #Evaluate(GetConditions.condition)#>
          
          <cfif result eq "yes">
               Passed #GetConditions.name#<br />
               <cfelse>
               Failed #GetConditions.name#<br />
          </cfif>     
     </cfloop>
</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2010 Feb 20, 2010

Copy link to clipboard

Copied

Do you wanna mark the question as resolved?

Cheers.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 20, 2010 Feb 20, 2010

Copy link to clipboard

Copied

LATEST

I figured it out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation