Skip to content

Local Variables

Akram El Assas edited this page Nov 1, 2022 · 1 revision

It is possible to declare local variables in a workflow.

The syntax is as follows:

<Workflow xmlns="urn:wexflow-schema" id="115" name="Workflow_FilesLoaderLocalVariables" description="Workflow_FilesLoaderLocalVariables">
	<Settings>
		<Setting name="launchType" value="trigger" />
		<Setting name="enabled" value="true" />
	</Settings>
	<LocalVariables>
		<Variable name="myFile1" value="C:\WexflowTesting\file1.txt" />
		<Variable name="myFile2" value="C:\WexflowTesting\file2.txt" />
		<Variable name="myFile3" value="C:\WexflowTesting\file3.txt" /> 
	</LocalVariables>
	<Tasks>
		<Task id="1" name="FilesLoader" description="Loading files" enabled="true">
			<Setting name="file" value="$myFile1" />
			<Setting name="file" value="$myFile2" />
			<Setting name="file" value="$myFile3" />
		</Task>
		<Task id="2" name="ListFiles" description="Listing files" enabled="true">
		</Task>
	</Tasks>
</Workflow>

When Wexflow server loads the workflow file, the workflow file will be parsed and thus the local variables will be replaced by their respective values.

It is also possible to combine global variables with local variables, here is an example:

GlobalVariables.xml:

<?xml version="1.0" encoding="utf-8" ?>
<GlobalVariables>
  <Variable name="wexflowTesting" value="C:\WexflowTesting" />
  <Variable name="fileName1" value="file1.txt" />
  <Variable name="fileName2" value="file2.txt" />
  <Variable name="fileName3" value="file3.txt" />
</GlobalVariables>

Below a sample workflow which contains global variables and local variables:

<Workflow xmlns="urn:wexflow-schema" id="115" name="Workflow_FilesLoaderLocalVariables" description="Workflow_FilesLoaderLocalVariables">
	<Settings>
		<Setting name="launchType" value="trigger" />
		<Setting name="enabled" value="true" />
	</Settings>
	<LocalVariables>
		<Variable name="myFile1" value="$wexflowTesting\$fileName1" />
		<Variable name="myFile2" value="$wexflowTesting\$fileName2" />
		<Variable name="myFile3" value="$wexflowTesting\$fileName3" /> 
	</LocalVariables>
	<Tasks>
		<Task id="1" name="FilesLoader" description="Loading files" enabled="true">
			<Setting name="file" value="$myFile1" />
			<Setting name="file" value="$myFile2" />
			<Setting name="file" value="$myFile3" />
		</Task>
		<Task id="2" name="ListFiles" description="Listing files" enabled="true">
		</Task>
	</Tasks>
</Workflow>
Clone this wiki locally