Calculation not working in Servoy application server.

Hi All ,

I have a calculation which is working fine in local developer . The Servoy version is 7.4.2 . But this is not working in the Servoy server . There is no server log message . This is a strange issue . The calculation is displaying nothing . I had tried out everything but the calculation is not working . Please help me . Please provide some suggestion .

Hi All ,

Please help me . I have also tried making it a stored calculation. But same problem .

Hi All ,

I would like to give some more input . This is working in local but not in servoy application server . This is servoy 7.4.2 . Simple calculation like “return 1” is also not rendering. Initially the form was list view . I changed to record view also it is not working . I duplicated the form , also it is not working . I have also tried with stored calculation it is also not working . I created a new calculation with only “return 1” it is also not working . Is this a servoy bug ? . It seems like the calculation is getting unassigned to the field automatically. Please help me .

Could you show the code for the calculation?
And did you put the calculation on a form, and you do not see any values calculated there?

And which servoy client (SC / WC / NG) is this about?
Calculations work fine for us in SC, although you have to take care not to overuse them due to performance reasons.

The code of the calculation is simple “return 1” . Yes I have put it in a form .

This is for smart client .

We use 7.4.5, but I guess you do not want to upgrade to just test this issue.
I would file a case for Servoy at https://support.servoy.com

Maybe your example is too simple, as a calculation is usually triggered by the change of other fields.
I would try the following:

  • restart the computer to have a clean memory
  • create a new table persons with
    ps_first_name
    ps_last_name
    ps_clcs_full_name
  • create a stored calculation for that table with
    name: ps_clcs_full_name
    function: return utils.stringTrim(ps_first_name) + " " + utils.stringTrim(ps_last_name)

Now put all three fields on a new form, create a first record and stuff some names to first and last name.
If that still is not working, you can create a case for Servoy with that example.

Thanks for your reply . You may be right . Actually calculation is not triggered as there is no change of other fields . So then how can I show such type of calculations ? .

if(utils.hasRecords(sms_log_to_emp) && (operator_id == globals.currentEmployeeID)){
		return '<html>' +
					'<body bgcolor="#ffff00">' +
						'SMS sent from ' + sms_log_to_emp.loginname + ' on ' + utils.dateFormat(sent_date , 'dd/MM/yyyy HH:mm') +
					'</body>' +
				'</html>';	
				
	}
	else if (utils.hasRecords(sms_log_to_emp) && (operator_id != globals.currentEmployeeID)){
		return '<html>' +
					'<body bgcolor="#ffffAA">' +
						'SMS sent from ' + sms_log_to_emp.loginname + ' on ' + utils.dateFormat(sent_date , 'dd/MM/yyyy HH:mm') +
					'</body>' +
				'</html>';
	}
	else{
		return null;
	}

Please provide your suggestion . In my example all relationships are working fine but the calculations are not showing. But one thing I would like to share the calculations are working fine in other parts of the application .

Please try first my example that I provided, because only then you have a general answer to the question “Do calculations work at all or not in my Servoy ?”

I would not recommend to use utils.hasRecords() inside a calculation, because - at least to my knowledge - utils.hasRecords() will issue a single SQL count.
You can mimic that by just adding and maintainig a counter to the basic record, so that it knows itself if it has children/linked records or not, without the use of utils.hasRecords().
Then you can use that counter in the calculation.

So try to take out the hasRecords() first and to replace it by an inner counter, it should work then.

Additionally, you could use a var sColor that you set inside the if-else, and then you make only one return after the if-else where you add the rest of your needed html code.
Makes the code more clean and lean.

Ah, and there is a final else branch with “return null” - it could also be that your function runs into that.
Replace it with a return “FINALE ELSE” temporarily to see if you are running into that else-branch.

Make sure your not accidently shadowing! To test that, change the name of the calc, add it to your form again, see if it works.
What can happen is you could have defined a form variable, javascript global variable, or something like that by the same name, it could be in conflict.