Not able to save calculated value into local variable

Certified Senior Developer

I am trying to calculate and save the value into local variable called local!grandtotal  using below code.

In the user interface I am able to see the value updated, But I am not able to see the value updated in the local variable.

Please advise some suggestions to resolve this.

  Discussion posts and replies are publicly visible

  • Saving a value into a local variable like what you want to have happen here, requires user interaction on a field.  You have the value of this field set correctly for showing the calculated total, however it won't actually perform the saveInto until/unless the user edits the field in some way and then clicks away.  I assume this is not what you want.

    Instead, you probably want your Grand Total field to be a read-only display; you have two options, one would be that you could calculate the Grand Total value in the value parameter of this field (which wouldn't solve the issue of saving it into local!GrandTotal), and the other option would be just basing it on local!GrandTotal -- in the latter case, you would need to do the calculation in the SaveInto fields of the other user input fields that it's based on -- maybe just local!cartDetails1.quantity.

  • A saveInto() will only get fired when the User interacts with that component. So, in fact, you'll need to include your saveInto() in the field that your user is interacting with i.e. the Quantity field. Your Grand Total field will then have its value set to the local! variable you're setting in the Quantity field, (and I presume your Grand Total field should be read-only to prevent someone from just over-writing it?(