A relationship comid$inv_to_com where comid = comid and global.gsevid = sevid.
I can place fields on a form based on this relationship, no problem. I can also set a text field via a method with a concatenation of fields, no problem. However if I put this same method into a calculation the elements are all returned as “undefined”.
In my experience there is some major issues with checking related values in calculations. So I think your calculation is failing at your “if” statements. On a number of occasions I’ve had to move logic that should work in calculations to methods as a result.
I think the problem has something to do with the order in which Servoy evaluates calculations and relationships. -STacktrace seems to confirm that relationships are not always evaluated before calculations in certain cases.
A tough problem to narrow down specifically but if the developers want to get nitty gritty with this I have a some indepth code with all kinds of versions that I used to figure this out a while back.
david:
In my experience there is some major issues with checking related values in calculations. So I think your calculation is failing at your “if” statements. On a number of occasions I’ve had to move logic that should work in calculations to methods as a result.
I think the problem has something to do with the order in which Servoy evaluates calculations and relationships. -STacktrace seems to confirm that relationships are not always evaluated before calculations in certain cases.
A tough problem to narrow down specifically but if the developers want to get nitty gritty with this I have a some indepth code with all kinds of versions that I used to figure this out a while back.
Thanks for the explanation.
I didn’t want to complicate my original question, but I have another table where the exact same calc is in place and it works. Your explanation of possible causes makes possible sense. I don’t like black holes.
As you’ve advised I’ve long since changed the procedure to use a method instead.
On a related note, I’d like to know how Servoy determines when it needs to run Calc methods. Questions I have include:
Is it constantly monitoring the dependencies of all the calcs?
If an event method modifies some variable that a calc depends on, does it re-run the calc immediately or does it wait until the event method completes?
Some general guidance on what NOT to do in calcs would be helpful because they are clearly an area where one can get into trouble if one tries to do too much.
I don’t say ‘this is the way to do it’ but my own guideline is that I only use simple calcs. Do row background colors etc.
Really complicated or timeconsuming stuff I do on datachange. That way I am in control…