It's actually pretty simple. Commands can be called from the browser location bar in an URL and functions can't. In nearly all other respects they are identical.
This has some usage implications, though. If you want to add an extra level of security to a routine you wrote, name it as a function, and people won't be able to execute it from the browser directly.
And there are two more trivia facts you should know about functions and commands:
- Some filters have to be named as commands or they won't work.
- Commands can be called from WCTL with the usual WCTL "use" syntax rather than the more convoluted JS call syntax:
%% use myCommand %%
rather than
%% "myCommand".jsCall() %%
And that's it. As you can see, in most cases it doesn't make a huge amount of difference which you use.
Slight expansion of one point: Most filters are part of the WCTL infrastructure. If you code one of them in SSJS, it has to be a command. But other filters - notably the email filters - are built in to the SSJS infrastructure, and they can be functions.
ReplyDeleteIt's a historical oddity from the way the codebase developed.
Thanks, I've clarified that above.
ReplyDelete