Calculation not working in Web Client

I have a calculation which works fine in smart client and in web client until I add a new row to the table.

When this happens all rows for the calculation displayed have the same value for the WC but work as expected for the SC.

Is there a differnece betweent the SC and WC that prevents this from working ?

Basically the code returns how many minutes from the current time to the date/time stored in the table

		var now = new Date();
		
// timeset is a date field
		var togo = timeset
	
		if (togo == null){
			return
		}

		var one_day=1000*60*60
		
		var minsNow = now.getTime()
		var minstogo = togo.getTime()
	
		var minsleft = (minstogo/one_day) - (minsNow/one_day)
	
		globals.glbl_calc_mins = minsleft * 60
		return Math.round(globals.glbl_calc_mins)

i dont know exactly what goes wrong there but your calc seems very wrong.

You are using a globals variable that you assign and then return (rounded)

But that variable is shared over all calculations so one will always override the other and so on.
So first don’t use “globals.glbl_calc_mins” but use a internal var like “var glbl_calc_mins”

var glbl_calc_mins = minsleft * 60
return Math.round(glbl_calc_mins)

On other problem with your code is when the calc is executed and you show it at time X
Do you expect when you show that calc again at X+1 hour that the calc is recalculated? That won’t be the case because if ‘timeset’ doenst change.

Maybe now this sort of works because you are constantly updating a global that then also invalidates and triggers recalculation of that calculation of other records.