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
BedrockMission!

Learn More

View all

Sign in to view all badges

Field Calculation

Avatar

Avatar
Validate 1
Level 1
awmackenzie
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
awmackenzie
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
awmackenzie
Level 1

24-01-2018

Hi,

I have created a Decimal field on a layout. I then have two other Decimal fields that are getting populated from the system. I want to try and subtract these two fields. I have been trying JavaScript and Formcalc, but cannot get it to work. It seems like it should be something easy to do. I would like to put this calculation on the "calculate" event.

First Field -> data.Page1.Position.ITEMS.TOTAL[0]

Field Subtracted from First -> data.Page1.Position.ITEMS.SALE

Calculation field -> data.Page1.Position.ITEMS.NEW

Any ideas how this can be done, or if it can?

Then I would like to hide the field if the calculated value comes back as zero, or empty. So I was going to try on the "initialize" event to add,

var new = data.Page1.Position.ITEMS.NEW.rawValue;

if (new == null || new == "" || '0')

{

   data.Page1.Position.ITEMS.NEW.presence = "hidden";

}

Any advice would be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

24-01-2018

Formcalc should be easiest if you are just subtracting fields to get an answer in another.

In the NEW calculate event it is simple as:

TOTAL - SALE

Thats all you need. As figures are changed in the TOTAL and SALE fields, the NEW field will update dynamically. It will also be automatically changed to read only so it cant be modified.

Hiding the field will need to be done in the field itself. It will only initialise when the form opens. If you want it to hide dynamically with the field's rawValue, put it into the calculation event also.

Note you will need to change your syntax for the formcalc if statement...or sometimes i put my javascript code separate hidden button and then programattically click a button.

You might need to account for getting the hidden field back as well if it isnt zero with an else on your if statement.

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
awmackenzie
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
awmackenzie
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
awmackenzie
Level 1

05-03-2018

Sorry for the delay. That helped out a lot.

Thanks again,
Andrew