schedule()

Usage

schedule(expression[[, title], onFinish])

Description
Allows the user to insert a script snippet into the import queue for later execution. Useful in situations where a script should run after a long-running import job, or if the script should run in a separate transaction that is independent of the calling transaction.

The title parameter is optional and is displayed in the structr admin UI in the Importer section and in the notification messages when a script is started or finished.
The onFinish parameter is a script snippet which will be called when the process finishes (successfully or with an exception).
A parameter jobInfo is injected in the context of the onFinish function.

The schedule function returns the job id under which it is registered.

Example

${schedule('call("myCleanupScript")', 'Cleans unconnected nodes from the graph')}

JavaScript Example

{
    Structr.schedule(function() {
        // execute global method
        Structr.call('myCleanupScript');
    }, 'Cleans unconnected nodes from the graph');
}

{
    Structr.schedule(function() {
        // execute global method
        Structr.call('myCleanupScript');
    }, 'Cleans unconnected nodes from the graph',
    function() {
        Structr.log('scheduled function finished!');
        Structr.log('Job Info: ', Structr.get('jobInfo'));
    });
}
About this article
Last change 2019-07-25
Topics