Hello,
in recent days I am getting increasingly strange errors from calculations. I see a warning sign in the lower left corner. Once I have an error like that switching between design and browse mode lets CPU usage go up to 99% until to point where I can hardly move the mouse. After sometimes several minutes I am back in business.
The errors I am getting are always the same: xy undefined.
Just to give an example, what kind of calc throws the error:
- a table with companies has a field standard_address_id, that is filled with one ID of 1:n addresses the company might have
- a calc returns for example the street of that address
In the meantime, I have tried to check FOR EVERYTHING that might go wrong, so the formula looks like this:
if (standard_address_id && companies_to_address_standard && companies_to_address_standard.street)
{
return companies_to_address_standard.street;
}
else
{
return null;
}
The relation companies_to_address_standard goes from companies.standard_address_id to address.address_id. The error given is companies_to_address_standard is not defined.
Can anyone tell me what I do wrong here?
When this occurs (not always, although I always look at the same data?!), I am basically out of business. Every move takes minutes. I have to restart, but most likely I am caught again.
Thanks
Patrick
to really see whats happening i need to see the solution but i would throw in a view application.output() like this:
application.output("main record size: " + controller.getMaxRecordSize());
if (standard_address_id)
{
if(companies_to_address_standard)
{
application.output("relation size:" + companies_to_address_standard.getSize());
if(companies_to_address_standard.street)
{
return companies_to_address_standard.street;
}
}
}
else
{
return null;
}
I think I nailed the problem. Looking at the stack trace, I saw that the error was thrown right after a specific query. Unfortunately, the situation is a bit complicate, so it takes a bit long explanation. Here is what I do:
the table view I am scrolling has a related field in it. That related field shows a checkbox (integer field in the related table) from a table “marks”. “marks” stores marked records for all kinds of tables. A user can check a certain record to mark it. In order to be able to do this for several tables, the “marks” table looks like this:
marks_id
table_name // the name of the table where records are marked
pk_data // the primary key of the record that is marked
user_id // the user who marks records
mark (integer)
In order to use this via a relationship, I need to join the user (a global on the left side), the primary key of a certain table and the table name itself. The table name is delivered by a calc in all tables that are “markable”, returning simply the table name, for example
return 'addresses';
If I show the field “mark” via that relation, I am getting into the trouble described. If I use a calculation instead of setting the dataprovider directly via the relation, that returns a 1 if there is a mark record, I am not in trouble.
The strange thing is, that Servoy complains about formulas that have nothing to do with the mark issue.
I think something goes wrong, if you use an unstored calc in a relation like I do. Strangely, it doesn’t always go wrong, not on every record (I don’t get an exclamation mark for all records), but if it does, you have to quit/kill Servoy.
Any idea of what goes wrong here?
Thanks
Patrick
very difficult to see from here what could go wrong.
but are you saying that when you have a field that directly builds on:
relation.mark
it goes wrong but if the field is build on a calculation that does this:
return relation.mark;
then it goes ok??
Is there a main record?
Yes, that is what I am saying. Very strange is the behaviour, though. Sometimes I start the solution, go to that table view and get an exclamation mark immediately. Other times I look at the same records, no problem. Then I start to scroll down and get errors. None of the errors relates to the mark thing, but to calcs that retrieve address data (completely different table, straight forward relation id_to_id etc.).
Now with a calc, I seem to have no problem. I changed the bahaviour a bit though. I leave the field mark since it is quite useless. If there is a record in marks, my record is marked. I don’t need an extra 1 there. So the calc does
if (table_to_marks.getSize() > 0) {
return 1; }
else {
return 0; }
The method that marks stuff simply creates or deletes records. The issue with the 1 probably came from one of my slower days… Or maybe because back then it was the only way to show a checkbox. Now, the user checks my calc, which is stupid, but since a method takes care of creating and deleting the marks, it’s OK.
Anyway, I am fine now, but something is wrong. ![Laughing :lol:]()
if you have some day a solution for me with these kind of things please send it over.