5 Replies Latest reply: Feb 19, 2013 9:41 AM by Henric Cronström RSS

Scripting, Created Fields, and Nested Statements

Travis Russo

Hi all,

 

I have a generic question for you that can be filed under "There has to be a better way."

 

So I am creating fields after loading data from a text file. A couple of the fields that I'm bringing in are List Price and Sale price. In the script I then calculate Savings $, Savings $, then other measurements to ensure List Price isn't less than Sale Price as that cannot happen.

 

Instead of doing the code similar to the following, is there a way to save these new fields to use them in the nested loops?

 

Psuedo code:

 

If (List Price = < 0,

     item price * amt shipped *1 //reverse credit,

          if (List Price < Sale Price,

               List Price = Sale Price,

                    If (isnull(List Price)

                         Unit Price * amount shipped,

                              List Price as [Revised List Price]

 

then it gets messier since I need to keep the formula going since the first one essentially found the "correct" list price. Then if the List price is negative, savings is negative, so on and so forth

 

If (List Price = < 0,

     item price * amt shipped *1 //reverse credit,

          if (List Price < Sale Price,

               List Price = Sale Price,

                    If (isnull(List Price)

                         Unit Price * amount shipped,

                              List Price

<

Sale Price,

Savings % = 0,

Sale Price as [Savings %]

 

etc etc etc. I know the above is messy but I cannot share exact code. I hope there is a way to "save" these created fields elsewhere to use in script but I don't think there is a way. I also need to show a table with the raw data in the dashboard, so I can't just do these with expressions when charting (for example).

 

Thanks!