How to pass parameters to Work Flow

July 02, 2014 by Anuraj

.Net ASP.Net WF Windows Forms

You can create arguments to workflow and can pass the values from outside. For creating arguments, you can use the Arguments Tab in the WorkFlow designer.

WF Arguments Tab

In the last post I mentioned about loading and invoking a WorkFlow, the WorkFlowInvoker class’s Invoke method has an overload, which accepts inputs parameter, which is type of IDictionary<string, object>. You can create an Dictionary<string, object> and pass it as the parameter to the Invoke method.

You can get the results from the WorkFlow in similar fashion, it is also returning IDictionary<string, object>. Here is the code snippet, which provides one input parameter and accepts the results.

var inputParameters = new Dictionary<string, object>();
inputParameters.Add("CurrentDate", DateTime.Now.AddDays(-20));
var result = WorkflowInvoker.Invoke(activity, inputParameters);
object timeAgo = string.Empty;
if (result.TryGetValue("Result", out timeAgo))

You can use any type as the argument type.

Happy Coding :)

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub