Skip to main content

Working with Workflows

Getting Workflows

To pull a workflow from Canvas to your local machine, run the cma: Get Workflow command. You will first be prompted to select a Canvas account from all the accounts you have access to.

With the account selected, the selection box will change to show all workflows on the chosen account. You can filter the selection box between deployed and undeployed workflows.

Selecting a workflow will cause the entire workflow to be pulled locally into the Workflows folder.

Getting a workflow that already exists in the folder will result in all code blocks being overwritten by the current Canvas code. You will be prompted to confirm, and also choose if you wish to overwrite existing outputs and variables.

Workflow Structure

Workflows are stored in a subfolder for the account, under the workflows parent folder. Each block in the workflow has its own subfolder a level below. Block code is stored in the .mjs (module JavaScript) file in the block folder within two commented regions:

//*** User code below this line ***

//*** User code above this line ***

Code within these regions is "user code" and is identical to what you see inside in the block in Canvas. Code outside of these comments is wrapper code for the extension and should not be edited.

Editing and Debugging Blocks

You are free to edit block code within the user commented regions in the same way as you would edit code in the block in Canvas.

To debug, you can press the F5 key and a debug session will begin. You can set your breakpoints and debug the block as you would any other code in VS Code.

Running Workflows

As well as debugging single blocks, you can also run workflows in the same way as you would in Canvas (run all blocks, or only selected). To run a workflow, open the "manifest.json" file in the workflow folder and then right-click the file and select the command "cma: Run Workflow". You will be prompted to run either the full workflow or make a selection of blocks to run.

Pushing Code Changes

To push code changes you've made in VS Code back to Canvas, open the block .mjs file and right-click the code file. Select the command "cma: Push Block Code". You will be prompted to confirm and then your code changes will upload and update the block.

info

The extension will reject the pushing of code changes to a mapper block. Code changes pushed to a template block will result in the block becoming "custom".

Setting Block Inputs

To view or change the inputs to a block, open the block .mjs file and right-click the code file. Select the command "cma: Set Block Inputs". A selection screen will open showing the current inputs to the block, if any.

info

You are free to change inputs, but note that input changes will not be pushed back to Canvas.