Solution Model newGlobalMethod is deprecated

Questions and answers for designing and implementing forms in Servoy

Solution Model newGlobalMethod is deprecated

Postby tkilshaw1553613063 » Mon Apr 08, 2019 8:41 pm

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
tkilshaw1553613063
 
Posts: 18
Joined: Tue Mar 26, 2019 5:11 pm

Re: Solution Model newGlobalMethod is deprecated

Postby Joas » Tue Apr 09, 2019 9:19 am

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 399 times


Note that using currentcontroller is also deprecated :)
Joas de Haan
Yield Software Development: Need help on your project?
yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 810
Joined: Mon Mar 20, 2006 4:07 pm
Location: Amersfoort, NL

Re: Solution Model newGlobalMethod is deprecated

Postby tkilshaw1553613063 » Fri Apr 12, 2019 7:54 pm

Thanks Joas.

Very helpful!

Terry
tkilshaw1553613063
 
Posts: 18
Joined: Tue Mar 26, 2019 5:11 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 1 guest