Hi guys,
This new post aims at describing one of my favourites stuff about vRO : The use of constants that I can call in all my workflows.
Just imagine that you defined some variables (like a folder to store log files, result files etc…) in several workflows and you have to change them. What a pity, you have to remind all the workflows that you set those variables in 🙁
Even if you know all your workflows, you won’t be motivated by the idea of modifying them, one by one
Constants are the solution 🙂
So let’s go
Let’s say that you want to run serveral statistics workflows and want to save the results into specifics files in a particular folder.
This folder must be unique and the files must be easy to identifty.
What I suggest is to create a set of constants for this specific need.
How ? By creating a configuration element, as described below :
- Open your vRO client
- Switch to the Design view
- Right-click to create a folder to store your constants
- Another right-click on your new folder to create, this time, an element
- Name it, for example, LogFoldersAndFiles
- In the “Attributes” tab, you create one or a set of variables (understand constants) :
- An attribute logFolderPath, as value, give it the path of the folder you will save your files in
- An attribute RequestsStatisticsLogFileName, as value, enter the name of a log file that will be used to store your statistics
- etc…
At this step, you’ve just saved a set of constants. Let’see how to use them in a workflow.
- Create a new workflow
- Create a new attribute :
- Name : hmmm… loggingProperties
- Type : ConfigurationElement
- Value : Click on “Not set” to define it and look for the name of the configurationElement
LogFoldersAndFiles
- Create a scriptable task
- Edit it and :
- Add as input variable your attribute loggingProperties
- Write the following code and run you workflow 🙂
var vroFolderPath = LogFoldersAndFiles.getAttributeWithKey("logFolderPath").value var logFileName = LogFoldersAndFiles.getAttributeWithKey("RequestsStatisticsLogFileName").value System.log("Your folder: " + vroFolderPath) System.log("Your file: " + logFileName )
That’s it. In a next post, we’ll see how to work with files 🙂