I have two related forms, one is in another’s tab. They are related but have two other linking tables between them.
The one that’s in the tab has two fields with the dataproviders being calculations from related tables.
When I update the foundset of this form (load a different record in it with loadAllRecords()) the two fields with the calculations are not updated. However, they are updated when I saveData(). I need to reflect the current state of the record. Is there a way to sort of recalculate the calculations before saving the data?
I have the same situation in another two forms that use calculations.
patrick:
databaseManager.recalculate() can be used to force Servoy to calculate those columns. Does that work for you?
Yes, it works Patrick!
Thanks a lot!
While we are still here shall I ask another question?
I’ve got two relations: one holds all related records in one table for a record in another table (onetable_to_anothertable); the other holds only one default related record (onetable_to_anothertable$default).
When I have no related records but create one in the default relation (onetable_to_anothertable$default.newRecord()) and then try to see the foundset for the other relation that should include the default record I can’t actually see anything there, it’s empty. I do onetable_to_anothertable.loadAllRecords() but it doesn’t help. Can you figure out what is missing?
Maria, Is your second relationship defined to allow the creation of related records through the relationship? If it is, and you are still having problems, the alternative which always works is to create the related record by copying the pk of one_table into a variable, creating a new record on a form based on other table and setting it’s fk to the variable. The following is example code run from the context of one_table
var theID = one_table_PK;
forms.other_table_form.controller.newRecord();
forms.other_table_form.other_table_FK = one_table_PK;
jkipling:
Maria, Is your second relationship defined to allow the creation of related records through the relationship? If it is, and you are still having problems, the alternative which always works is to create the related record by copying the pk of one_table into a variable, creating a new record on a form based on other table and setting it’s fk to the variable. The following is example code run from the context of one_table
Thanks, Jeremy. That’s what I did.
I’m afraid that the link between the tables was too long. After all, I changed the base table of one of the forms to a closer linking table and it worked.
Maria,
I’m glad you got it to work. I just realized I had an error in my code. That code might work, but it would be better to use the variable theID in the last line, rather than the primary key directly.