Script Launcher Component
Using the Script Launcher component, it's possible to start a child script from your main script. Child scripts have their own script configuration and behave just like a regular script.
Usage
When implementing your script's onStart, execute, or onFinish methods, you can access the Script Launcher
component through the provided ComponentProvider.
fun execute(provider: ComponentProvider) {
val scriptLauncher = provider.scriptLauncher()
// Launch a child script by its ID
val childScriptId = "com.example.childscript"
val scriptResult = scriptLauncher.launch(childScriptId)
// Check the result of the child script execution
if (scriptResult.success) {
provider.logger().info("Child script completed successfully")
} else {
provider.logger().error("Child script failed: ${scriptResult.errorMessage}")
}
// Launch with custom configuration parameters
val config = mapOf(
"productId" to "12345",
"quantity" to "2"
)
val configuredScriptResult = scriptLauncher.launch(childScriptId, config)
}
Child Script Communication
Child scripts can communicate back to the parent script through their execution result. Data can be passed between scripts, allowing for modular script design with specialized sub-tasks.
More Information
For more detailed information about using child scripts, including passing data between scripts and managing script lifecycles, please refer to the child script documentation page.