Page 1 of 1

Solution Model newGlobalMethod is deprecated

PostPosted: Mon Apr 08, 2019 8:41 pm
by tkilshaw1553613063
In the Servoy Wiki:

https://wiki.servoy.com/display/DOCS/So ... del-Create

it gives this example:

var globalMethod = solutionModel.newGlobalMethod('function myGlobalMethod() { currentcontroller.newRecord(); }');

But in Version: 8.4.0.3402 the newGlobalMethod is shown as deprecated.

What should be used instead?

thanks,

Terry

Re: Solution Model newGlobalMethod is deprecated

PostPosted: Tue Apr 09, 2019 9:19 am
by Joas
You should also specify the name of the global scope in which the method should be added:
Code: Select all
var globalMethod = solutionModel.newGlobalMethod('yourScope', 'function myGlobalMethod() { currentcontroller.newRecord(); }');

If you don't specify a scope name, the method is added in the "globals" scope, but using that scope is discouraged, because those methods can be called using a deeplink which might be a security risk.

Also: When pressing <Alt> when hovering a deprecated method, you'll get a tooltip with an @deprecated tag explaining what to use instead:
screenshot_deprecated.png
screenshot_deprecated.png (10.19 KiB) Viewed 3593 times


Note that using currentcontroller is also deprecated :)

Re: Solution Model newGlobalMethod is deprecated

PostPosted: Fri Apr 12, 2019 7:54 pm
by tkilshaw1553613063
Thanks Joas.

Very helpful!

Terry