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

Evaluate Formula Stored in Database

New Here ,
Jul 12, 2009 Jul 12, 2009

Copy link to clipboard

Copied

I'm trying to allow users to store formulas in a database field to allow them to create their own analysis page.

I have set of variables that the user can use to create their formulas.

The problem I'm coming across is that I can't get the database formula to evaluate.

For example.

I have the following variable that is already set.

     <cfset Cost = "12500">

If my user decides to add a repair line to their analysis the formula could be saved in a database field name LineItemFormula and the formula would look something like this.

     Cost * 0.05

Then when the repair line is diplayed I want to display and store the value:

     625

I can't seem to get the database formula to evaluate.

I tried #evaluate(de(LineItemFormula))# but that just displays

     12500 * 0.05

So I tried evaluating this new string and I get

     String index out of range: 0 null

If anyone can give me some advice on what I'm doing wrong or if what I'm trying isn't possible I would appreciate it.

Thanks

Torri

TOPICS
Advanced techniques

Views

961

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 ,
Jul 12, 2009 Jul 12, 2009

Copy link to clipboard

Copied

write the code stored in the database to a file and cfinclude the file.

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
New Here ,
Jul 12, 2009 Jul 12, 2009

Copy link to clipboard

Copied

LATEST

Dan

That worked. Thanks.

Plus your way I'm not having to run the query to get the formula each time.

Torri

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