Overview
JavaScript Task is an SSIS Control Flow Task that allows automation of any custom logic in the control flow. It is an alternative of Microsoft Script Task and COZYROC Script Task Plus. It is also a more flexible replacement of Microsoft Expression Task.
By choosing JavaScript for implementing custom control flow logic, you will significantly simplify the development and maintenance of your SSIS scripts. For more details about the benefits of JavaScript scripting, please look here.
Editor
The Editor Dialog contains the following tabs:
Parameters tab
The Parameters tab displays the parameters, defined in the script, and their current values. For more detailed information about defining and using script parameters see here.
Properties tab
Referencing code from another JavaScript Task
To avoid code duplication, the code of a JavaScript Task can be stored in another JavaScript Task. The properties under the Linked Task category allow referencing the source JavaScript Task:
- PackageConnection - allows choosing the package, where the source JavaScript Task is (i.e. the current package or an external one).
- JavaScriptTask - allows selecting the source JavaScript Task in the selected package.
If you have specified a source JavaScript Task, you can unlink it later by clicking the button Remove link below.
Customizing the execution and validation logic outside the script code
Under the Script category there are two properties:
- Expression - specifies JavaScript expression that will be executed. If not specified,
task.run
would be run. - Validation - specifies JavaScript expression that will be used to validate parameters. If not specified,
task.validate
would be used.
Usually, the execution expression is defined in the script code by implementingtask.run
. But having a separate Expression property provides additional opportunities for code reuse - e.g. two JavaScript Tasks might share a script, but they can execute different logic by configuring different expressions to run.
Script tab
The tab displays the JavaScript script code. It allows editing and adding breakpoints. The embedded editor is the one that comes with the particular version of Visual Studio. For detailed information how to automate SSIS tasks with JavaScript, please refer to the API Reference.
At the bottom of the dialog, there are two buttons that make it convenient to load the JavaScript code from a file and save the code to a file.
Quick Start
We will setup a parameterizable JavaScript Task to automate a simple scenario - checking if a file exists and saving the result in a boolean variable.
See the debugger in action
To start debugging, close the JavaScript Task Editor and execute the package. During the execution another instance of the Visual Studio will be launched and the debugger will stop at the first breakpoint.
After verifying that the script works as expected, close the VSTA instance.
Knowledge Base
- Where can I find the documentation for the JavaScript Task?
- Is there a way to set the parameters of a Javascript dynamically when using Javascript Task.
- Where can I find scripts for the JavaScript Task and the JavaScript Component?
- Microsoft Dataverse - A Template for Close Opportunities as WON or LOST
- Microsoft Dataverse - A Template to Cancel Sales Order
What's New
- Fixed: An ocassional error "The directory is not empty" in the post-execution cleanup (Thank you, Saikit).
- New: Commands to quickly Copy/Paste user parameters.
- Fixed: Incorrect variable replacement in JSON.
- Fixed: Disabled various destructive commands in the script editor.
- Fixed: Improved memory consumption and management.
- Fixed: Removed not needed exception popup dialog because the error is already reported in the log.
- New: Introduced task.
Related documentation
COZYROC SSIS+ Components Suite is free for testing in your development environment.
A licensed version can be deployed on-premises, on Azure-SSIS IR and on COZYROC Cloud.