Page History
Workflow scripts allow you to launch scripts from the context menu of a selected object and act on itperform actions programmatically on one or multiple objects within RED. For example, you can create a workflow script that exports the DDL for one or multiple objects or for performing GIT operations like Check-in or Check-out on a set of objects. You can launch scripts from the context menu of one or multiple selected objects.
Note | ||
---|---|---|
| ||
The Worflows Workflow context menu only shows when you have created a Workflow Host Script. |
Adding
...
a Workflow script
This section provides examples on how to create Workflow scripts.
Before Creating a Workflow, you first need to add a Workflow host script language type. For instruction instructions on adding a new language type refer to Adding a Host Script Language Type.
Export the context of an object
This example shows how to export the context of an object as a JSON structured file.
Using Workflow Scripts
Adding the script
- Create a language type called ps workflow
- Set the file extension to ps1
- Set the command to PowerShell -ExecutionPolicy Bypass -File "$SCRIPT_NAME$"
- Set the category field to Workflow.
- Click OK.
- Add a new Metadata Object Type.
- To add a new object, right click on the Host Script node.
- Select New Object.
- For this example, enter Print Context as a name.
- Click OK.
- In the configuration window, set the type to ps workflow script, set the appropriate Owner and Connection Name for your data.
- The new script should appear on the Host Script node.
- Right click on Print Context and select Edit the Script. This will open the script on a new tab.
- On the edit script tab enter the following code:
Code Block language powershell write-output 1 write-output 'Printing context' # print the expected context file write-output "---- First 20 lines of context file: `n$PSScriptRoot\wsla${ENV:WSL_SEQUENCE}.objects`n----" if (Test-Path -path "$PSScriptRoot\wsla${ENV:WSL_SEQUENCE}.objects") { get-content -path "$PSScriptRoot\wsla${ENV:WSL_SEQUENCE}.objects" -TotalCount 20 | write-output } else { write-output "*** Error: Objects file doesn't exist as there were no objects in the current context. ***" }
Running the Script
To run the script, right click on an object, go to Workflows, and select Print Context.
Verify the script ran successfully.
To check the output files, go the temp foldera