studio
2024.10
true
UiPath logo, featuring letters U and I in white

Studio User Guide

Last updated Dec 19, 2024

Integrating Low-Code workflow in Coded automation

In this tutorial, you can learn how to incorporate a low-code workflow inside a coded automation. This example is similar to the Using Coded automation in Low-Code workflow tutorial, but the other way around. The tutorial shows how to invoke the ResetAssetValue.xaml low-code workflow into the CodedAutomationUsingWorkflow.cs coded automation.
The ResetAssetValue.xaml workflow performs the following steps:
  1. Retrieves the current value of a specific asset from Orchestrator.
  2. Compares the retrieved asset value with the input value provided as an argument.
  3. If the previous asset value does not match the input value, it updates the asset value in Orchestrator.
  4. Logs messages that indicate the status of the asset value, whether it was updated or remained unchanged.
  1. Create a low-code workflow. For this example, name it ResetAssetValue.
    Note: Leave the value of all variables and arguments you create empty. These variables and arguments will be populated with data when you invoke the low-code workflow within a coded automation. You will pass the required values for these arguments when you invoke the workflow.
    1. Add a Get Asset activity, and save the name of the asset in a variable named assetName.
    2. Create arguments for the following values:
      1. assetValue - the In/Out argument that you use to retrieve and update the value of the asset.
      2. assetName - the In argument that you use to input the name of the asset.
      3. assetValueWasChanged - the Out argument that you use to print in the console if the asset value remained the same or was changed.
    3. Create a variable to pass the previous value of the asset: previousAssetValue.
    4. Add an If activity to check if the previous asset value has changed. Set the Condition as previousAssetValue.Equals(assetValue).
    5. In the Else body, add a Set Asset activity, to update the asset in Orchestrator with the assetValue that is different from the previousAssetValue.
    6. Add an Assign activity and update the previous asset value with the new one.
      assetValue = previousAssetValue
    7. Add another Assign activity to set the variable that lets you know if the asset value has changed to True.
      assetValueWasChanged = True
  2. Create a new coded workflow. For this example, name it CodedAutomationUsingWorkflow.
    1. Use the RunWorkflow method to invoke the ResetAssetValue.xaml workflow.
    2. Provide the necessary arguments as a Dictionary<string, object> to specify the assetName and assetValue.
      For this example, we set MyAsset as the assetName and "hello world" as the assetValue.
    3. Store the result of the RunWorkflow method in a variable named result.
      var result = RunWorkflow("BusinessProcess\\ResetAssetValue.xaml", new Dictionary<string, object>()
            {
              {"assetName", "MyAsset"},
              {"assetValue", "hello world"}
            });var result = RunWorkflow("BusinessProcess\\ResetAssetValue.xaml", new Dictionary<string, object>()
            {
              {"assetName", "MyAsset"},
              {"assetValue", "hello world"}
            });
    4. Check if the assetValueWasChanged property in the dictionary is true or false.
      1. If it's true, log a message that indicates the asset MyAsset was reset and include the previous value it had.
      2. If it is false, log a message specifying that no reset was required on the asset MyAsset because it had the expected value.
        if ((bool)result["assetValueWasChanged"])
              {
                Log("Reset asset MyAsset, but it had a different value, previous value was " + result["assetValue"]);
              }
              else
              {
                Log("No reset was required on asset MyAsset, which had the expected value.");
              }if ((bool)result["assetValueWasChanged"])
              {
                Log("Reset asset MyAsset, but it had a different value, previous value was " + result["assetValue"]);
              }
              else
              {
                Log("No reset was required on asset MyAsset, which had the expected value.");
              }

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.