Calculated column creates Edited Records

Forum to discuss the new web client version of Servoy.

Calculated column creates Edited Records

Postby dev-ws-011 » Thu Sep 30, 2021 12:27 pm

Hi All,

We are having problem with using calculations. Below are 2 scenarios:

1) Stored Calculations:
- Consider a calculation which updates based on date
- We are able to sort on this Calculated column. (Required to sort on this column)
- Now, if sorting is applied on foundset and calculation is updated then next sorting fails to work because records are edited. We cannot apply AutoSave as this is not intended.

2) Simple Calculations (Not stored):
- Foundset sorting is working fine as expected.
- But we cannot sort on this Calculated Column.

Suggestion:
If for Stored calculations, some Servoy internal save data call may update calculations ONLY. As this will resolve edited record issue and finally resolve sorting issue. Or sort functionality may be enabled on simple calculations as well.

Any help shall be highly appreciated.

Regards
Servoy Developer
dev-ws-011
 
Posts: 73
Joined: Fri Oct 21, 2016 8:23 am

Re: Calculated column creates Edited Records

Postby jcompagner » Thu Sep 30, 2021 1:12 pm

if the record where the stored calc is on has already other changes or you don't want to autosave
then no the record will not be saved (so stored will not be in the database)
if we are going to make all kind of exceptions to this rule this is weird, you say don't save then we don't save.
Is very weird that stored calcs are then special, what if the depend on other unstored stuff and so on?
the calc could even be a foreign key that is calculated somehow but that thing its pointing to is not saved yet, then the save will fail..
(there could be more of those in the database that checks for valid data)

you can sort on un stored calls but you need to sort in memory using sort(function) that does mean you need all the data
sorting in the database on data thats not in the database is impossible
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Calculated column creates Edited Records

Postby dcamargo » Thu Sep 30, 2021 4:02 pm

Stored Calculations
You don't need to have autoSave enabled just identify when you need to save the edited records i.e.: before foundset.sort(), before foundset.find()
Saving the foundset will solve your sorting problem and allows you to keep the stored calculation which will make the sorting faster and easier

Non-stored Calculations
As jcompagner said, you can use foundset.sort(function) and it works like the regular js array sort function (receives two parameters and return -1, 0, or 1)
This is also the only option if you can't save the edited records before sorting for stored calculations
Danny Camargo
Servoy & Web Developer
dcamargo
 
Posts: 13
Joined: Tue Aug 23, 2016 8:59 pm


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 8 guests

cron