Unstable: relation using calculated fields

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

Unstable: relation using calculated fields

Postby shaikna » Wed Jan 28, 2004 7:28 pm

I am facing a problem with my solution. Let me explain it in diff parts...

brief:
I got 3 tables.. Gallery, Group & History. Group is like a master table. One Gallery record can be linked to one or more Group records. This linking is recorded by History.

requirment:
I have a linking form based by Gallery table. It should show two portals: left one contains all Group records not yet linked to Gallery & right one contains all Group records that are already linked to Gallery. You may vision it as a list of choices available on the left and those already chosen on the right and the user can easily move the records in between them. (This concept is more common with many applications).

logic:
To achieve the two portals, I have created a calculated field both in Group & History and say it as Group_Gallery_cd. Again, I hv created another calculated field "available_status" and the value is return using a script. The logic is, if Group.grp_gal_cd matches in History.grp_cal_cd, then return 0 (linked) otherwise return 1 (available). So, simple the left portal shoud return records if "available status"=1 and right one with =0.

probs:
At first show, the result was not perfect. So, I go to Group record list and checked the calculated field values. They are not updated. But, when I clicked on that record and moved to next, it changed to the correct value. strange? (refresh probs?). Thn, I came back to link form, it shows perfectly. But, again for the next Gallery, it is not okay. That means, if I go to Group record everytime, then only it refreshes.

Any idea about such problem? Any solutions?. Awaiting your quick reply. Thanks.
_________
shaikna
shaikna
 
Posts: 38
Joined: Wed Oct 08, 2003 6:42 am

Re: Unstable: relation using calculated fields

Postby bcusick » Wed Jan 28, 2004 7:49 pm

shaikna wrote:probs:
At first show, the result was not perfect. So, I go to Group record list and checked the calculated field values. They are not updated. But, when I clicked on that record and moved to next, it changed to the correct value. strange? (refresh probs?). Thn, I came back to link form, it shows perfectly. But, again for the next Gallery, it is not okay. That means, if I go to Group record everytime, then only it refreshes.


Servoy doesn't "update" the calculated values automatically. I assume these were STORED calculations (i.e. the calculation is mapped to a physical column in the database). The way around this - [ONE TIME OPERATION] is to go to your history and group files (or wherever the calculations are) find all records and go to each record (this will force an update of the calculation). Here's some code you can use to go to each record in a form (GLOBAL script):


currentcontroller.loadAllRecords();

for ( var i = 1 ; i < currentcontroller.getMaxRecordIndex() + 1 ; i++ )
{
currentcontroller.recordIndex = i;
}
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA


Return to Programming with Servoy

Who is online

Users browsing this forum: Bing [Bot], mboegem and 16 guests