0 votes

Hi guys,

We can call a serverscript in multiple ways (and we can find both in the standard).
For now (Efficy 11.2), and for the futur, Is there a way better than the others ? Is there a depracate way ?

  • Utils.runServerJsAjax
  • Utils.runScriptAjax2
  • $.ajax({
    url: ...,
    method: ...,
    data: ...
    }).done(function (html) {
asked in Efficy/ Client side by (336 points)

1 Answer

+1 vote

Hi Vincent

For me it's quite clear that everything inside serverscripts should be considered legacy. Serverscripts are loaded with <%LoadScript()%> and <%RunScript()%> and within this scripting environment, you can't import ServerJs modules. Everything is global and this is by definition also less secure.

The goal is that we never write duplicated code or have to work with libraries with global functions. This idea is incompatible with serverscripts.

ServerJS allows you to share code between all filebases (Efficy, Extranet, Guest, Shared) and as well with Db Workflow.

With ServerJS we create structure by making folders and sub-folders. Each function should be stored in a separated file. On top of that file, import modules that are consumed by that global function. The library modules are true modules and by design private to the outside.

Conclusion, what you should use for new developments in Efficy 11.2+ are:

  • runServerJsAjax
  • runNodeAjax

If you are only returning JSON, work only with runNodeAjax.

PS. Documentation will follow when it gets the highest priority :-)

answered by (6.8k points)
Thx Kristof,

it is important to make sure that this is used in this way.
I think that passing on a message to say something like "serverscript and old way to run server side script is depracate and only keeped available for backward compatibility" can be a good idea because if we see in the past (from Efficy 2012 to Efficy 2014 ), we can see that people often keep their old habits.
I didn't see any runNodeAjax in the standard, have you an exemple of using this somewhere ?
I believe it's introduced by R&D for the Workload module developments and it's only part of the Submariners branch of Efficy 11.2. It's indeed not yet part of standard 11.2. But you can of course add it already manually :-)
1,167 questions
1,425 answers
325 users