Servoy 8.2 Smart Client vs NG Client issue: passing a form

Hi, take the following code:

		var menu = plugins.window.createPopupMenu();
		menu.addMenuItem('Companies', scopes.nav.go_to_screen).methodArguments = [event, forms.companies_main];
		menu.addMenuItem('Contacts', scopes.nav.go_to_screen).methodArguments = [event, forms.contacts_main];
		menu.addSeparator();
...

and

/**
 * @param {Number} arg1
 * @param {Number} arg2
 * @param {Number} arg3
 * @param {Number} arg4
 * @param {Number} arg5
 * @param {JSEvent} event
 * @param {RuntimeForm} a_form
 *
 * @properties={typeid:24,uuid:"E28E8FD9-261D-4905-B35D-1014111A0266"}
 */
function go_to_screen(arg1, arg2, arg3, arg4, arg5, event, a_form) {
	a_form.controller.show();
	scopes.globals.setupRecordStatus(a_form);
}

I am deliberately using the actual form in the code, this way Servoy will show an error if I try to reference a form which does not exist.

This works fine in Smart Client, the form object is passed to the go_to_screen function. In NG Client, it looks like the form_name is passed instead of the form object.
So the above code has to be rewritten as:

/**
 * @param {Number} arg1
 * @param {Number} arg2
 * @param {Number} arg3
 * @param {Number} arg4
 * @param {Number} arg5
 * @param {JSEvent} event
 * @param {String|RuntimeForm} a_form
 *
 * @properties={typeid:24,uuid:"E28E8FD9-261D-4905-B35D-1014111A0266"}
 */
function go_to_screen(arg1, arg2, arg3, arg4, arg5, event, a_form) {
	if(application.getApplicationType() == APPLICATION_TYPES.SMART_CLIENT) {
		a_form.controller.show();		
	} else {
		forms[a_form].controller.show();
	}
	scopes.globals.setupRecordStatus(a_form);
}

to work. Not a big issue as it is easy to rewrite the code to make it work by passing the form name, but it meant my main-menu did not work at first in NG-client.

Can the NG-client handle objects like forms in parameters?

In my opinion there should be no difference in coding the same stuff in smart-client and ng-client.
So my advice is, to report this into Servoy support system, with a reproducable sample.

I wouldn’t recommend building your menu like that at all, neither in smart of NG (if the latter would even work :-) )
Each form reference you’re using will result in Servoy caching the form already.

I don’t know how many entries you do have in the menu, but seems to me that first time build of this menu could be pretty slow.
Just pass the name of the form and show it through the code you mentioned in the rewrite.

forms[a_form].controller.show();

Yes, passing them menu name makes the menu appear faster the ride time.

I wrote it like that because I wanted Servoy Developer to pick up if any forms where missing or form names were misspelt.

swingman:
I wrote it like that because I wanted Servoy Developer to pick up if any forms where missing or form names were misspelt.

Would be better to write unit-test to perform this check, or if you don’t like the idea, use the solutionModel to validate the formname by creating a JSForm instance and see if that returns result.
A JSForm instance doesn’t instantiate your form instance, so will be lightning fast :-)

Hope this helps