Expand my Community achievements bar.

SOLVED

Need help on calculate

Avatar

Level 2

I need to calculate 3 numeric fields and have a "A" at the 4th textField.

example numericField1=40 numericField2=40 numericField3=20   and numericfield4 is the sum of 1, 2  and 3 so the total is =100 on numericfield4

if this total is 100 then the letter A has to be the value of TextField1

I did it this way on calculate - javascript

if (numericField3 > 90 && numericField3 <100) {

(TextField4 = "A");

}

Well somthing like that and work.

What I need and I have no Idea how to do it, is to have a more results(letter) like if the sum is between 70 and 89 the letter is B and if is between 50 and 69 the letter is C.

but also if numerifield1= to 35 then even if the total is between 90 and 100 the Letter change to B

here is why:  NumericField1 corresponds to COLOR. NumericField2 corresponds to DEFECT. NumericField3 corresponds to CARACTER and NumericField4 corresponds to the total puntiation. if the puntuation is between 90 and 100 is a GRADE A product

but if the puntuation is between 90 and 100 but the NumericField1 is = to 35 then the result even is between 90 and 100 must be a letter B (or grade B)

I don't know if I did it clear. hope so and hope some one can help me.

Thank You

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

I think I understand.

//form1.page1.subform1.grade_::calculate - (JavaScript, client)

if (!(form1.page1.subform1.total_.rawValue == "" || form1.page1.subform1.total_.isNull)) {

  var n_ = form1.page1.subform1.total_.rawValue;

  if (form1.page1.subform1.color_.rawValue == 35) {

    this.rawValue = "B";

  }

  else {

    if (n_ > 89) {

      this.rawValue = "A";

    }

    else {

      if (n_ > 69) {

        this.rawValue = "B";

      }

      else {

        if (n_ > 49) {

          this.rawValue = "C";

        }

        else {

          this.rawValue = "";

        }

      }

    }

  }

}

Steve

View solution in original post

4 Replies

Avatar

Correct answer by
Former Community Member

I think I understand.

//form1.page1.subform1.grade_::calculate - (JavaScript, client)

if (!(form1.page1.subform1.total_.rawValue == "" || form1.page1.subform1.total_.isNull)) {

  var n_ = form1.page1.subform1.total_.rawValue;

  if (form1.page1.subform1.color_.rawValue == 35) {

    this.rawValue = "B";

  }

  else {

    if (n_ > 89) {

      this.rawValue = "A";

    }

    else {

      if (n_ > 69) {

        this.rawValue = "B";

      }

      else {

        if (n_ > 49) {

          this.rawValue = "C";

        }

        else {

          this.rawValue = "";

        }

      }

    }

  }

}

Steve

Avatar

Level 2

YOU ARE THE MAN. Thank you. It works perfect.

Thank you

Dank

Grazie

Obrigado

Merci

Avatar

Level 2

what if I need a value range colo_ field?

is this ok

                   

//form1.page1.subform1.grade_::calculate - (JavaScript, client)

if (!(form1.page1.subform1.total_.rawValue == "" || form1.page1.subform1.total_.isNull)) {

  var n_ = form1.page1.subform1.total_.rawValue;

  if (form1.page1.subform1.color_ .rawValue > 32 && color_.rawValue < 35) {

    this.rawValue = "B";

  }

  else {

    if (n_ > 89) {

      this.rawValue = "A";

    }

    else {

      if (n_ > 69) {

        this.rawValue = "B";

      }

      else {

        if (n_ > 49) {

          this.rawValue = "C";

        }

        else {

          this.rawValue = "";

        }

      }

    }

  }

}

Also need this for defect_ and character_

Avatar

Level 2

Please need help also for character and defect.

same as the one in color but in the same script.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----