We have a form in our API that we use for basic searches over all our solutions. The name of the form is "base_lookup". Now a have a special case and I need a slightly different search algorithm only for that case. Therefore I changed the function code on the form with:
- Code: Select all
// Remove changes to avoid stale form
history.removeForm("base_lookup");
solutionModel.removeForm("base_lookup");
solutionModel.revertForm("base_lookup");
forms.base_lookup.controller.recreateUI();
// Remove old function and insert new one (with same name)
lookupForm.removeMethod(myOldFunction);
lookupForm.newMethod(myNewFunction);
// Maybe unnecessary...
forms.base_lookup.controller.recreateUI();
That works fine. I can do my special search.
But when I do a second search with this form, I get an error like this.
Stale form(s) detected, form(s) were altered by the solution model without destroying them first
The form(s) that are stale (can also be a parent form if form inheritance is used) are:
Form name:'base_lookup' with instances: [base_lookup8B9BCCE8-0E21-4768-8D5D-93FA9F3991CE]
at C:\Servoy\Data\omsv_bazu_8\omsv_bazu\bazu_za.js:113
I know this error happens, when already created forms are changed and not recreated properly. So I tried all combinations with history.removeForm(), solutionModel.removeForm(), forms.base_lookup.controller.recreateUI(), ... (It's also the reason why there are two forms.base_lookup.controller.recreateUI() in the code, just to make sure.)
I think the problem happens in a different place. I our API we create the search form like this:
- Code: Select all
var luUUID = application.getUUID();
var luFormNamHpt = "base_lookup" + luUUID;
application.createNewFormInstance("base_lookup", luFormNamHpt);
This will create every time a new instance of the form with the name "base_lookup" and a random UUID. Also the error message says there is a instance with the name "base_lookup8B9BCCE8-0E21-4768-8D5D-93FA9F3991CE". Even it's not good that there will be everytime a new instance created when the user does a search, I don't want to change this code, because it works well for a long time.
So my 3 questions are:
1: Does the stale form problem happen because of the instance?
2: Is there a way to get a reference to the instance? With solutionModel.getForm("base_lookup8B9BCCE8-0E21-4768-8D5D-93FA9F3991CE") it looks like I get a reference to the original form "base_lookup".
3: Is there a way to get rid of an instance? E.g. application.removeFormInstance() or something.
Thanks Gregory