activities
latest
false
UiPath logo, featuring letters U and I in white

Workflow Activities

Last updated Dec 20, 2024

Data Map

This tutorial demonstrates how to create and work with a Data Map component. You will learn how to pass data to it, update it dynamically while the form is displayed, and extract the data. In this example, we will focus on currency rates, using a dictionary with key-value pairs representing different currencies and their equivalent values in USD. By interacting with buttons, you can extract and modify the currency rates in real-time while the form remains visible.
  1. Create a new form and add the following components:
    1. Add a Data Map component. Remember the Property Name you assign to it, because you will use it to extract and dynamically update the data in the component.
      In this example, use dataMap as the Property Name.
    2. Add a Button component to extract the data in the component. Set the Action of the button as Event.
      Name the button Extract data.
    3. Add another Button component to change the data in the component. Set the Action of the button as Event.
      Name the button Update value.
  2. In the Main workflow create a dictionary variable and add key-value pairs to it.
    In this example, use the key-value pairs shown in the image below.


  3. Add a Show Form activity with Continue workflow execution enabled. This allows the form to display while other trigger workflows run simultaneously.
    1. In the Arguments collection, pass the previously created dictionary variable to the Data Map component in your form.
  4. Add a Run Local Triggers activity to enable all triggers in your project.
  5. Create a trigger workflow for updating values in the Data Map at runtime.
    Name the trigger workflow fieldChangedTrigger.
    1. Add a Form trigger activity, and set the Event as the button used for updating the Data Map values.
      In this example, set the Event to Update value clicked.
    2. Add a Get Form Values activity to extract the current values of the Data Map into a dictionary variable.
      In this example, save the current values to a variable named dataMap2.
    3. Use a For Each activity to iterate through each key-value pair and update them with a specific value.
    4. Inside the For Each activity, add an Assign activity to initialize a new key-value pair that you want to update the Data Map with.
      • Save the pair to a variable named newItem using the Save to field.
      • Specify the new key-value pair using the Value to save field: New KeyValuePair(Of String, String)(currentKeyValuePairOfTextAndText.Key, currentKeyValuePairOfTextAndText.Value).
    5. Within the For Each activity, add an If activity to conditionally modify the EUR pair. Configure the condition using the object used to iterate through the Data Map.
      In this example, configure the following condition: currentKeyValuePairOfTextAndText.Key = "EUR"
    6. Inside the Then body of the If activity, add an Assign activity to update the newItem value with the desired new value.
      • Use the Save to field to assign the newItem variable.
      • Use the Value to save field to provide the new value of the pair: CType(New KeyValuePair(Of String, String)("EUR", "1.19 USD"), KeyValuePair(Of String, String)).
    7. Add another Assign activity to map the new value back into the dictionary.
      • Use the Save to field to update the corresponding key-value pair in the dataMap2 variable.
      • Use the Value to save field to assign newItem.Value to dataMap2(newItem.Key).


    8. At the end of the workflow, add a Set Form Values activity to update the Data Map inside the form with the modified values.
  6. Create a trigger workflow to extract values from the Data Map at runtime.
    Name the trigger workflow extractDataTrigger.
    1. Add a Form trigger activity and set the Event as the button used for data extraction.
      In this example, set the event to Extract data clicked.
    2. Add a Get Form Values activity to extract the current values of the Data Map at runtime. Save the Data Map into a dictionary variable.
    3. Use a For Each activity to iterate through each key-value pair in the Data Map and output them in the console.


In the animated image below, witness the dynamic update of values within the Data Map as you click the Update value button.


Workflow example

To follow the steps and try out the tutorial yourself, check out the sample project here.

  • Workflow example

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.