Calculation not working in Servoy application server.

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Calculation not working in Servoy application server.

Postby ashutoslenka426 » Tue Aug 16, 2016 6:08 am

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 .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Calculation not working in Servoy application server.

Postby ashutoslenka426 » Tue Aug 16, 2016 8:20 am

Hi All ,

Please help me . I have also tried making it a stored calculation. But same problem .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Calculation not working in Servoy application server.

Postby ashutoslenka426 » Tue Aug 16, 2016 3:50 pm

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 .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Calculation not working in Servoy application server.

Postby Bernd.N » Tue Aug 16, 2016 4:33 pm

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Calculation not working in Servoy application server.

Postby ashutoslenka426 » Tue Aug 16, 2016 5:07 pm

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

This is for smart client .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Calculation not working in Servoy application server.

Postby Bernd.N » Tue Aug 16, 2016 5:12 pm

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
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Calculation not working in Servoy application server.

Postby Bernd.N » Tue Aug 16, 2016 8:29 pm

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Calculation not working in Servoy application server.

Postby ashutoslenka426 » Wed Aug 17, 2016 5:56 am

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 ? .
Code: Select all
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 .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Calculation not working in Servoy application server.

Postby Bernd.N » Wed Aug 17, 2016 10:03 am

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Calculation not working in Servoy application server.

Postby sbutler » Sat Aug 20, 2016 4:05 pm

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.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 11 guests

cron