2 Replies Latest reply on Mar 31, 2015 1:05 AM by martins82060393

    script

    martins82060393 Level 1

      Hi, i hope someone can help me.

       

      I have this Custom Calculation field:
      ColorField('AdjustedCO2Reading',ValidateWithSetPoint('CO2SetPoint','AdjustedCO2Reading',0. 2));

       

      I would like it to have:

      -1 > 0.2 = Do this (Coloring)

      0.21 > 0.7 = Do this(Coloring)
      0.71 > 100 = do this(Coloring)

       

       

      ColorField Custom Script:

      function ColorField(AFieldName,AOK)

      {

         var f=this.getField(AFieldName);

       

       

         if (AOK || f.value == 'N/A')

            f.textColor=color.black;

         else

            f.textColor=color.red;

         return AOK;

      }

       

      I would like 3 different colors in the ColorField Script for the values abobe in the "Custom Calculation Field".

       

      Hope someone can help

        • 1. Re: script
          hasand59089870 Level 2

          A week ago you already have a topic presented. Why you don't leaditon there. We take the time to help you. Please rate at the end of our effort.

           

          Have you seen my adapted code

           

          function coloring(xvalue, setPoint) {

            fvalue = Math.abs(setPoint - xvalue)

            if (fvalue <= 0.2) {
              event.target.textColor = color.black
            } else if (fvalue > 0.2 && fvalue < 0.7) {
              event.target.textColor = color.blue               
            } else if (fvalue >= 0.70) {
              event.target.textColor = color.red
            } }

           

          var fl = this.getField("AFieldName-Low")
          fl.setAction("Format", "coloring(event.value, this.getField("AFieldName-Setpoint").value)") ;

           

          var fh = this.getField("AFieldName-High")
          fh.setAction("Format", "coloring(event.value, this.getField("AFieldName-Setpoint").value)") ;

           

          • 2. Re: script
            martins82060393 Level 1

            Oh yeah, just saw. I'm sorry, didn't see. :-(