How to Invoke a Workflow using Invoke Code activity

Team,

Please help to know how can i invoke a workflow using code?

   Dim argInvokeFile As Uipath.Core.Activities.InvokeWorkflowFile = New Uipath.Core.Activities.InvokeWorkflowFile

    Dim activity As System.Activities.WorkflowInvoker 
    Try
    argInvokeFile .WorkflowFileName ="Search.xaml"
    activity = New WorkflowInvoker(argInvokeFile ) 
    activity.Invoke()
     
    Catch ex As Exception
     throw
    Finally
       argOpenBrowser1 = Nothing
       activity = Nothing
    End Try

Kindly help to know how i pass arguments within the code as well, Thanks for your support.

1 Like

Why are you trying to reinvent something that already exists?

RD

In the existing method do we have control over the object? and
one more query do the object get destroyed once the execution is over?

The reason I’m asking is if i debug a project with 20 odd xaml uipath stops responding with a msg box “workflow designer” and
error msg “MemoryOut exception” I don’t know the exact error message but i get something like this.

I have to close the application and open again.
pls help to know to why i get this message.

Thanks

Hi @Ifham21,

Did you ever find a way to invoke a workflow within an invoke code block? I need to do something similar. I need to run a workflow impersonating another user.

Thanks!

Troy

Hello, I tried and worked,

'Simple Invoke Workflow, with out any Parameters
System.Activities.WorkflowInvoker.Invoke(System.Activities.XamlIntegration.ActivityXamlServices.Load(“Test2.xaml”))

System.Windows.MessageBox.Show(“In invoker Workflow”)

''Invoke Workflow, with Input, Output, InOut Parameters
’ Setting Dictionary and store Input, InOut Parameters
Dim paramDictionary As IDictionary(Of String, Object) = New Dictionary(Of String, Object)()
paramDictionary.Add(“in_Num1”, 10)
paramDictionary.Add(“in_Num2”, 20)
paramDictionary.Add(“inout_Message”, “Hi”) 'Setting InOut parameter in Invoker Workflow
'Setting Dictionary to store Out, InOut Parameters
Dim resultDictionary As IDictionary(Of String, Object) = New Dictionary(Of String, Object)()
'Invoking the Workflow
resultDictionary= System.Activities.WorkflowInvoker.Invoke(System.Activities.XamlIntegration.ActivityXamlServices.Load(“Test2.xaml”), paramDictionary)
System.Windows.MessageBox.Show(“Invoker Workflow prints Out Parameter:” + Convert.ToString(resultDictionary(“out_Result”))) 'Printing Out Parameter
System.Windows.MessageBox.Show(“Invoker Workflow prints InOut Parameter:” + Convert.ToString(resultDictionary(“inout_Message”))) 'Printing InOut Parameter

1 Like

Logging doesnt seem to be working with this method. An invocation is thrown if the target workflow is using log message in the workflow file.

1 Like