is there ever a reason to use the controller.loadRecords() as opposed to the foundset.loadRecords().
The reason I ask, is that i think there is a servoy glitch or even bug with the controller. function.
This is I think related to calling it from a sub function on another form.
i.e
function a {
function b()
}
function b{
form2.controller.loadRecords(foundset.id);
... then do some stuff to print a pdf on form2.
}
We have found that sometimes the wrong record has been attached to an email we are sending when compiling a few attachments.
Recently it occurred after i had a script, which i decided to split out into 3 subscripts for ease of reading it, and this it appears started to cause a similar problem to that which I have seen before.
Anectdotally, it doesnt appear to be an issue when making the call from the first function on the form on which it is called, only when you go to a sub function on the same form. I have also checked the foundset.id and this is correct in the sub function, as another document, which uses it works fine within the same script.
I am hoping that using the form2.foundset.loadRecords(foundset.id), will work, and it appears to.
So is the controller.loadRecords function essentially not necessary as the founder. function will do the same thing, even if i use the controller.print in the next line?
will need a clear head in the morning to think about what its saying. Maybe a coffee and a tea!
Interesting all I am doing is loading in the id of the record I am on into a form with a template for printing a report, so i am not sure that either shouldnt work.
It was the changing of the function which loaded the record into the other form before issuing the print command to create a pdf, that has worked fine for ages, but it was only when i moved it to a sub function on the same primary form that it seemed to do this sporadically.
At first i thought it was loosing the foundset.id when moving to the second function, even though it was on the same form js as the first, but this cant be the case as one letter, which sends a global text variable to a form with a letter template and everything as a global displays this id as it put in the variable as our ref: '+foundset.id and that is displaying fine!
I will try to reproduce it somehow, but I have changed to controller.loadRecords() and I will see if in ViVo this stops the problem.
This look strange indeed.
the only possible way is that: controller.print(), does strange stuff with the foundset, don’t know, but maybe you can workaround it…
why not holding the id (or a whole record object) right at the beginning in a var, and than use that in the end in the mail??
and ofcourse after that, do some more debugging, so you can reproduce this, and Servoy could take a look at this…
Loaded the wrong record into my found set!!! It is intermittent, but happening once or twice every day. The record is created a few minutes earlier and saved, hence the id is on the main table as an fk.
Most odd. I have put the script on the form now and used 4 methods to get the record, (foundset.load, controller.load, then foundset.find()) so maybe i can see if one works even after the foundset.loadRecords failure.