I’m trying to use the solution model functions for the first time in servoy 5.1.1 and I put together a a small chunk of code in the onShow() event that seems to work except that I get an error the first time the cloned form is shown:
My code:
function onShow(firstShow, event)
{
// get an existing form
var form = solutionModel.getForm(‘frmwk_dbmaintenance_main’);
// make a clone/copy from it
var clone = solutionModel.cloneForm(‘clonedForm’, form);
// Create a first child form.
var childOne = solutionModel.newForm(‘childOne’, ‘bw’, ‘contact’, ‘null’, false, 400, 300);
childOne.newField(‘lastname’, JSField.TEXT_FIELD, 10, 10, 100, 20);
// Create a relation to link the parent form to the first child form.
var parentToChild = solutionModel.newRelation(‘parentToChild’,‘bw’,‘address’,‘bw’,‘contact’,JSRelation.INNER_JOIN);
parentToChild.newRelationItem(‘id’,‘=’,‘address’);
// Create a second child form.
var childTwo = solutionModel.newForm(‘childTwo’, ‘bw’, ‘contact’, ‘null’, false, 400, 300);
childTwo.newField(‘lastname’, JSField.TEXT_FIELD, 10, 10, 100, 20);
// Create a tab panel and add two tabs to it, with the two child forms.
var tabPanel = clone.getTabPanel(‘tabs_gridview’);
// var tabPanel = form.newTabPanel(‘tabs’, 100, 100, 300, 300);
tabPanel.newTab(‘tab1’, ‘Child One’, childOne, parentToChild); // The first form uses the relation.
tabPanel.newTab(‘tab2’, ‘Child Two’, childTwo);
}
The error:
name ‘clonedForm’ invalid for the clone of frmwk_dbmaintenance_main
Wrapped java.lang.RuntimeException: name ‘clonedForm’ invalid for the clone of frmwk_dbmaintenance_main (/Users/Chuck/bw_workspace/frmwk_dbMaintenance/forms/frmwk_dbmaintenance_main.js#86)
at /Users/Chuck/bw_workspace/frmwk_dbMaintenance/forms/frmwk_dbmaintenance_main.js:86 (onShow)
Other than the above, the cloned form looks right and has the additional tabs. It also seems to function fine after I dismiss the error. I’m sure whatever it is that I’m missing is very simple. Can anyone help?