Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Highlight a field after calculation

figbag22
Level 1
Level 1

I'm a novice at scripting and events so my question is going to sound silly and may not use the correct terminology.  Please look beyond that.

Using Formcalc, I'm multiplying a currency value against an exchange rate to give a value in US dollars.  See "Calculation" below.

I'm trying to use field Actions to change the background/foreground colors when the result of this calculation is greater than a limit, in this case, 10,000.  Using the action buttons produces the script below (See Format field if calculated result...). 

The problem is that LCD inserts this code BEFORE the code for the calculation.  Because the field has not yet been calculated, errors do not highlight.

I've copied the code from the two components into Notepad and I've tried to move them so they are in the correct order (see part three below).  However, I get syntax errors. 

This is such a simple thing.  Can anyone help me?

*********  Calculation  *********

form1.Velocity_limits.#subform[0].#subform[1].USD_value_1::calculate - (FormCalc, client)

USD_value_1 = Currency_value_1 * Exchange_rate;

********   Format field if the calculated value exceeds the limit  ************

form1.Velocity_limits.#subform[0].#subform[1].USD_value_1::exit - (JavaScript, client)

//+ GENERATED - DO NOT EDIT (ID:45771E5A-579E-4330-8FAB-490B9927685A CRC:3835840347)

//+ Type: Action

//+ Result2: SetForecolor("$Node1","255, 0, 0")

//+ Result1: SetFillColor("$Node1","255, 255, 153")

//+ Node1: form1[0].Velocity_limits[0].#subform[0].#subform[1].USD_value_1[0]

//+ Condition1: NumericField("$Node1","greaterThan","10000")

//+ ActionName: USD_value_1.exit

if (this.resolveNode("$").rawValue > 10000) {

  this.resolveNode("$").ui.oneOfChild.border.fill.color.value = "255, 255, 153";

  this.resolveNode("$").fontColor = "255, 0, 0";

}

//-

*******  Reordered in Notepad  ***********

form1.Velocity_limits.#subform[0].#subform[1].USD_value_1::calculate - (FormCalc, client)

USD_value_1 = Currency_value_1 * Exchange_rate;

form1.Velocity_limits.#subform[0].#subform[1].USD_value_1::exit - (JavaScript, client)

//+ GENERATED - DO NOT EDIT (ID:45771E5A-579E-4330-8FAB-490B9927685A CRC:3835840347)

//+ Type: Action

//+ Result2: SetForecolor("$Node1","255, 0, 0")

//+ Result1: SetFillColor("$Node1","255, 255, 153")

//+ Node1: form1[0].Velocity_limits[0].#subform[0].#subform[1].USD_value_1[0]

//+ Condition1: NumericField("$Node1","greaterThan","10000")

//+ ActionName: USD_value_1.exit

if (this.resolveNode("$").rawValue > 10000) {

  this.resolveNode("$").ui.oneOfChild.border.fill.color.value = "255, 255, 153";

  this.resolveNode("$").fontColor = "255, 0, 0";

}

//-

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

You have the formatting code on the exit event of USD_value_1, however using a calculate event to assign a value will not fire the exit event.  You need to add an action on the Currency_value_1 fields exit event, like;

1030202_pastedImage_2.png

If the Exchange_rate field can be entered by the form filler you will need a similar action (on exit of Exchange_rate) as well.

Regards

Bruce

View solution in original post

2 Replies
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

You have the formatting code on the exit event of USD_value_1, however using a calculate event to assign a value will not fire the exit event.  You need to add an action on the Currency_value_1 fields exit event, like;

1030202_pastedImage_2.png

If the Exchange_rate field can be entered by the form filler you will need a similar action (on exit of Exchange_rate) as well.

Regards

Bruce

View solution in original post

figbag22
Level 1
Level 1

Bruce - you are the guy!  This absolutely performed the way I wanted.  Such a simple thing to understand and I had no clue what to look for.  Thank you very much.