How to pass parameters to Work Flow

Posted by Anuraj on Wednesday, July 2, 2014 Reading time :1 minute

.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 :)

What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.

Similar Posts

Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon

BMC logoBuy me a coffee

Copyright © 2019 - Anuraj P. 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. Hosted with ❤ by GitHub