Skip to main content
Participant
February 11, 2019
Answered

I need to reference a calculation field to bring back a value in another field

  • February 11, 2019
  • 2 replies
  • 632 views

This field is calculating correctly based on the value in equipment

the field name is LevelRate

var nEquipment = this.getField("equipment").value;

if (nEquipment<=49999)
    event.value = .0550;
else if  (nEquipment>=50000)
    event.value = .0525;

I want to reference LevelRate in another field

if LevelRate is .0550 the new field VariableRate need to be .0574

I'm trying this but it's not working I tried calculation order and putting it in validate vs. calculate

this.getField("LevelRate").value

if (LevelRate=.0550)
    event.value = .0574;

else if (LevelRate=.0525)
    event.value = .0549;

This topic has been closed for replies.
Correct answer Bernd Alheit

Try this:

LevelRate = Number(this.getField("LevelRate").valueAsString);

if (LevelRate == .0550)

    event.value = .0574;

else if (LevelRate == .0525)

    event.value = .0549;

2 replies

cechcherAuthor
Participant
February 11, 2019

Bernd,

This is brilliant, thank you so much. I'm a non-coder and just trying to hack it

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
February 11, 2019

Try this:

LevelRate = Number(this.getField("LevelRate").valueAsString);

if (LevelRate == .0550)

    event.value = .0574;

else if (LevelRate == .0525)

    event.value = .0549;

try67
Community Expert
Community Expert
February 11, 2019

I would also add this line at the end, just in case the result is neither one of those values:

else event.value = "";