Skip to main content
Known Participant
January 25, 2022
Answered

How to create a running balance

  • January 25, 2022
  • 3 replies
  • 4807 views

Hi everyone,

 

I am trying to create a running balance (totalaed1 amount to be added to current balanceaed1) using to the following code

 

event.value = 0; if (this.getField("Totalaed1").value >= 1) event.value = this.getField("Totalaed1").value - this.getField("balanceaed1").value;

 

For some reason the result doesnt match.

 

Thanks for your help

 

 

 

This topic has been closed for replies.
Correct answer Nesa Nurani

I might be wrong but the script does not show in the field section 


 If "totalaed" is >= 1 you  are substracting current field value from "totalaed" and showing new value.

Is there something else you want script to do?

3 replies

Nesa Nurani
Community Expert
Community Expert
January 26, 2022

If result doesn't match it's probably field calculation order, while in 'prepare form' tool click on 'More' then 'set field calculation order' and make sure that field where you use script is under "Totalaed1" and "balanceaed1" fields.

Fab787Author
Known Participant
January 26, 2022

I ended up in calculated fields but I don't have the knowledge to know the correct order. 

 

 

 

Nesa Nurani
Community Expert
Community Expert
January 26, 2022

Move field where you use script all the way down so it is below "Totalaed1" and "balanceaed1".

Bernd Alheit
Community Expert
Community Expert
January 26, 2022

Where does you use this script?

Fab787Author
Known Participant
January 26, 2022

I used the script in balanceaed1field calculate and custom calculation script

try67
Community Expert
Community Expert
January 25, 2022

Are there any errors in the JS Console?

Fab787Author
Known Participant
January 25, 2022

here is what I found in the debugger (complete chineese for me I'm a beginner)

 

SyntaxError: syntax error 9: SyntaxError: missing ( before formal parameters 1: TypeError: f is null 1282:byteCodeTool TypeError: f is null 1282:byteCodeTool TypeError: this.getField(...) is null 3:Field:Validate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate SyntaxError: missing ; before statement 3: TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate TypeError: this.getField(...) is null 3:Field:Calculate