I am trying to create and use a return variable created by Add-WfaWorkflowParameter as part of an execution expression, and I would be gracious for some help. We are running WFA 184.108.40.206.1 Build 5039721.
For DR in my environment, I have to mount SnapMirror destination volumes and make them available via CIFS or NFS, depending on the security style. WFA doesn't allow uninitialized "DP" volumes to be given a junction-path, so my WFA workflow has to initialize the SnapMirror relationship before I can mount the volume.
To error-proof this process, I have added logic to the "Create SnapMirror" command Powershell to create a WFA Return Parameter (called "SnapMirrorInitialized"). If the SnapMirror initialization is successful, the value is set to "True"; in any other result (SnapMirror can't be created or initialized), the value is set to "False".
After the "Create SnapMirror" step is the "Mount Volume" step. For the Parameters information, under the "Advanced" tab, I have configured "Execute this command:" to "If the following expression is TRUE". The expression is ' SnapMirrorInitialized="True" '.
The workflow is configured so that if the source or the destination volume cannot be created (i.e, the creation fails or the volume already exists), the "Create SnapMirror" step is disabled, and this works as expected.
However, When I run a preview of the workflow while specifying a volume that already exists, every step is properly disabled except for the "Mount Volume" step. The "If the following expression is TRUE" doesn't seem to be applying, and the step executes even though "SnapMirrorInitialized" shouldn't exist.
Here are my questions:
What explains this behavior?
Can I use return variables in this way, and if so what steps/settings am I missing?
Are there other ways to pass a value created in a Command's Powershell script to the WFA Workflow?
If I am following the question correctly, this is expected behaviour. The preview function, does not execute any of the command code. If just checks inputs, filters, finders, templates and input functions for the commands. Since your code sets the variable, that variable does not exist during preview.
If I'm not mistaken, expressions in WFA are written in MVEL (a subset of Java), and a conditional like you have should have 2 '==' signs, like this:
I believe that your expression as written ( SnapMirrorInitialized="True") assigns the string value of "True" to the variable ' SnapMirrorInitialized', which evaluates to 'True', and the step is executed.