Are you familiar to the workflow constants? I don’t think that it is well-known function, so I would like to introduce that because it is very useful.
What’s the “Workflow Constants”?
“Workflow Constants” is literary the fixed value which you can set and use in your workflow. It could be set and confirmed on the Workflow tab in the Workflow Configuration window.

Workflow Constants types
There are three types in the Workflow Constants, two of them are generated automatically by system and another is created by user.
Type : Engine
Designer generates the some Workflow Constants as “Engine” types.
- TempFilePath:The path which is used to save the temporary files by Engine.
- Version:Designer Version
- WorkflowDirectory:The folder path of the workflow file
- WorkflowFileName:The name of the workflow file
- GuiInteraction:When the workflow run by GUI, the value will be set “True”. If not, it will be “False”. For example, running on Server or command line, it would be “False”.
Moreover, when the workflow type is “Batch Macro”, “Iterative Macro” or “Location Optimizer Macro”, you can see the additional workflow constants as follows.
- IterationNumber:The number of times the macro was repeated. This number is 0 based.
These constants are automatically generated by system, so you can not change this value directly.
Type : Question
When you create Analytic Apps or macros, you usually use the tools in the Interface category. In this case, Designer automatically adds the constants for the interface tools as “Question” type.

The interface name is used as the constant name. However, the default tool name is not easy to understand, so I recommend it’s better to give them the descriptive name.

Type : User
You can create the constants as “User” type. Let’s create it actually. When you create the constants, you can do them at the right top “+” button on the Workflow Configuration window as follows.

When you click on the “+” button, a new item will be created. Here, you can type the name and value.

For example, I would like to create “tax” constant. For this, you can create a new constant and type name and value. The “#” in the right column is an indicator that this is a number. If you uncheck this check box, the value is handled as string.

How can I use?
The workflow constants are able to use in the Formula tool and the file path in the Input Data tool. If you want to use them, you write them with its “Type”. For example, you want the workflow name, its type is “Engine”, so you should input “[Engine.WorkflowFileName]”.
Use in the (Multi-Row/Multi-Field) Formula
This is about using constants in expressions.
Let’s calculate the tax using the workflow constants. You put the Formula tool into canvas, you can select [User.tax] through the popup as follows.

The completed formula is as follows:

The result is as follows.

This is the correct way to use the constants. But it is only able to use in the expression editor.
Use in the Input/Output Data tool
This is the way to use the constants in the Input/Output Data tool, which is called as Reference Shortcuts.
Next, let’s use the constants in the Output Data tool. I write the file name in the workflow constants as follows.

Next, let’s use this constant as output file name. At this time, I use it as relative path, which is that I only write the file name, so Designer will create the file under the folder with the workflow.

To use the constants in the Input/Output Data tool, you have to enclose the workflow constants with “%”, not bracket “[]”. This way is called as Reference Shortcuts. Please be aware that the help document says “Be cautious when you use this method, as it might not always produce the expected results”. It can be used in the expression editor and text box.
This way also can be used by Question type constatns. So, you can use as follows, too.

For debugging, please enter the default file name at the Workflow Configuration windows because the default value is empty. When you run the workflow as Analytic App, this value will be overwritten by the interface tool’s input.
Conclusion
It is a bit complex, so here’s a summary of how to use it.
Type | Expression editor | Text box |
---|---|---|
Engine | CAN USE “%Engine.constname%” [Engine.constname] | CAN USE %Engine.constname% |
Question | CAN USE “%Question.constname%” [Question.constname] | CAN’T USE |
User | CAN USE “%User.constname%” [User.constname] | CAN USE %User.constname% |
I would introduce some characteristic ways.
Use as a new column name in the Formula tool
You can use the constants as a new column name in the Formula tool. For example, supposed to be created it as follows.

For the Fomula tool, you can set the constants as follows.

It is reflected as follows.

Like this, the column name is not in the expression editor, [User.NewFieldName] is not worked. In this case, you have to use them enclosed by % at the new column name.
about “Question” type
According to the knowledge base, Question type can not be used by bracket enclosed. Indeed, there is no Question type constants in popup list.

But you can use the bracket enclosure as follows entering directly.

Or, you can also use “%” as the enclosure. In this case, you have to enclose by the double quotations moreover as follows.

Anyway, when you run the workflow using Question type constants, its output is as follows.

Because the default value is empty, so you have to enter the specific value for debugging.

Use case
Debugging for the Batch Macro or Iterative Macro
When you create Batch macro or Iteative macro, to save the data which is created in each iterative run is easire to debug. For this way, add the [Engine.IterationNumber] constants to the file name and save it. Especially, when you create the Iterative macro, the output value changes with each run. However you save the output in each run, debugging is becoming very easier.
Specify DB connection destinations collectively
When you want to write data to the multiple table of the database, you use some Output Data tools. In this case, it is annoying to change the all output connection. To make this easier, you can include an Output Data tool in the Batch macro and set the connection destination to be changed by a Text Box tool, and then specify workflow constants to the Text Box.
Conclusion
- I have introduced the Workflow constants.
- Using Question type constants is a bit complex, so I recommend to use the Interface tool with Action tool.
- Since it is difficult to keep an eye on rewriting workflow constants, if you have to change them, please make it clear in the workflow or document that the workflow constants must be rewritten.
- In my point of view I feel that it is best not to use it if there is no consensus on its use within your organization.
- However, it is easy to centrally manage and can be very powerful depending on the use case.
Sample Workflow Download
Reference URL
The next blog post is…
The next post will be about BUD.
コメント