Subscribe

Return parameters for operation results

I'm working on a custom command in WFA for polling two controllers for option differences. I have the results in an array, but I'm having a hard time figuring out how to get that output to the workflow user. I see the return parameters tab in the workflow results window and I'm wondering how I can get the results into that tab so the user can see the differences. Any ideas?

Re: Return parameters for operation results

This is possible in WFA 2.2RC and onwards.  If you are using powershell commands you will need to add this line in your command

Add-WfaWorkflowParameter -Name volumeOptions -Value $volOptions -AddAsReturnParameter

and for perl it is

my $wfaUtil = WFAUtil->new();

$wfaUtil->addWfaWorkflowParameter(‘volumeOptions’, $volOptions, 1);

  The Add-WfaWorkflowParameter and Get-WfaWorkflowParameter are primarily used for transferring information between commands during execution. The last parameter -AddAsReturnParameter adds the value as a return parameter to the workflow

Re: Return parameters for operation results

Add-WfaWorkflowParameter -Name volumeOptions -Value $volOptions -AddAsReturnParameter

-Value takes only a string argument, and as you said you have an Array, you can't use the array object directly. I suggest you join the array object to a string and then use it in the above command.. Something like below.

# Joining on a colon :

$volOptions = $volArray -join ":"

Add-WfaWorkflowParameter -Name volumeOptions -Value $volOptions -AddAsReturnParameter



If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: Return parameters for operation results

Thanks for the info. I'll run an upgrade and try it out!

Re: Return parameters for operation results

Is there any improvements in wfa 4.0 version with Add-WfaWorkflowParameter.

 

Francois

 

Re: Return parameters for operation results

No.

Anything specific you are looking for?

 

Regards

Abhi

Re: Return parameters for operation results

I think the main missing thing is add-wfaworkflowparameter accept only [string] type. Array of objects  will be great.

 

François

Re: Return parameters for operation results

@francoisbnc

 

It may not be possible for the WFA cmdlets to accomodate other data types like array or hash etc.

 

But there is a simple way to get this done. You can easily use join and spilt methods to join the elements of an array to form a string.

 

 $a= @("1","2","3")

 $value = [System.String]::Join("~",$a)   #Choose a separator which you are sure not an element in the array. Typically ~ or _ can work,

 

Add-WfaWorkflowParameter -Name "MyArray" -Value $Value

 

 

 

-----

 

In the next command where you want this array, get the value and call split on it.

 

 

$value = Get-WfaWorkflowParameter -Name "MyArray"

$a = $value.Split("~")

 

Now you got your Array as you wanted.

 

Similar methods are available in Perl for the WFA command in perl.

 

sinhaa

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: Return parameters for operation results

[ Edited ]

@francoisbnc

 

 

I think you wanted array of Objects  and not just an array, did you?

 

This is not possible with cmdlet, the cmdlet writes this dynamic name-value pair into a file and then fetches this data back to you. 

 

The same join-split can help you in this case too.

 

sinhaa

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: Return parameters for operation results

Yes it is.

 

Many return values is difficult to read and maintain, a simple objet or array of objects would simple to manage.