Multiply two integer fields and save the results to another field.

I'm trying to multiply the values stored in two integer fields and save the results in another integer field. I'm not sure if I have the correct syntax for the multiplier in my code or if my saveInto statement is correct. The Total estimated capacity field is not displaying the results of the value in the Number of files field multiplied by the value in the Average file size field  This is my code:

a!integerField(
  label: "Total estimated capacity",
  value: ri!totalEstCapacity,
  saveInto: {
    a!save(ri!totalEstCapacity,ri!numberOfFiles*ri!averageFileSize)},
  refreshAfter: "UNFOCUS",
  required:true,
  validations: {}
)

Can someone help with this?  Thanks...

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    If the value of "total estimated capacity" is supposed to be auto-calculated, then the saveInto of its field is not the place to do this.

    Assuming that you require the multiplied value to be saved into the variable ri!totalEstCapacity as soon as both of the precedent fields are filled, with strictly no further input from the user, then you would do the saveInto in both of the precedent fields (do it the same way in both of them, and in both cases make them check to ensure both values are non-null before doing the operation). The "total estimated capacity" field should probably then be read-only as you won't be allowing its value to be changed directly.

    A more flexible way (though it gets more complicated) is to do the math operation within a with() variable which will auto-update as soon as the two precedent fields' values change. But getting the multiplied value saved into your ri! is a step more complex.
Reply
  • 0
    Certified Lead Developer
    If the value of "total estimated capacity" is supposed to be auto-calculated, then the saveInto of its field is not the place to do this.

    Assuming that you require the multiplied value to be saved into the variable ri!totalEstCapacity as soon as both of the precedent fields are filled, with strictly no further input from the user, then you would do the saveInto in both of the precedent fields (do it the same way in both of them, and in both cases make them check to ensure both values are non-null before doing the operation). The "total estimated capacity" field should probably then be read-only as you won't be allowing its value to be changed directly.

    A more flexible way (though it gets more complicated) is to do the math operation within a with() variable which will auto-update as soon as the two precedent fields' values change. But getting the multiplied value saved into your ri! is a step more complex.
Children
No Data