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

Feb 11, 2019

Copy link to clipboard

Copied

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;

Try this:

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

if (LevelRate == .0550)

    event.value = .0574;

else if (LevelRate == .0525)

    event.value = .0549;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

76

Likes

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

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

Feb 11, 2019

Copy link to clipboard

Copied

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;

Try this:

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

if (LevelRate == .0550)

    event.value = .0574;

else if (LevelRate == .0525)

    event.value = .0549;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

77

Likes

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
Feb 11, 2019 0
Feb 11, 2019

Copy link to clipboard

Copied

Try this:

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

if (LevelRate == .0550)

    event.value = .0574;

else if (LevelRate == .0525)

    event.value = .0549;

Likes

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
Reply
Loading...
Feb 11, 2019 0
Feb 11, 2019

Copy link to clipboard

Copied

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

else event.value = "";

Likes

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
Reply
Loading...
Feb 11, 2019 1
cechcher LATEST
Feb 11, 2019

Copy link to clipboard

Copied

Bernd,

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

Likes

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
Reply
Loading...
Feb 11, 2019 1