apps
2023.4
false
Apps User Guide
Automation CloudAutomation Cloud Public SectorAutomation Suite
Last updated Apr 19, 2024

Using Data Context

Background Information

Overview

Before starting this example, make sure that you have the proper permissions from Data Service. For more information, check the Data Service - Managing Access page.

For the purpose of this example we will use an entity called Customer with the following fields:

  • Address
  • Address 2
  • City
  • Email
  • Name
  • Phone
  • Plan
  • State
  • Postal Code

Setting up Data Context

  1. Open your already existing application or start a new one.
  2. Create a new table.
  3. Add an entity to your app by clicking the Add any icon from the top of the canvas and selecting Entity.



  4. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  5. Add the following expression in the Data Context field of the main page: =Lookup(Customer, [Name, "=", "Demo"]).


  6. Add a new textbox control.
  7. Add the Name data context in the Default Text field of the textbox control. Preview the app and the textbox should display the text configured using data context.



Using Data Context in Rules

Create/Update Entity Record Rule

Data context can only be used to update an existing entity using the Create/Update Entity Record rule.

  1. Open your already existing application or start a new one.
  2. Create a new table.
  3. Add an entity to your app by clicking the Add any icon from the top of the canvas and selecting Entity.



  4. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  5. Add the following expression in the Data Context field of the main page: =Lookup(Customer, [Name, "=", "Demo"]).


  6. Add a new button control.
  7. Configure a Create/Update Entity Record rule for the button. Add the Customer-Main Page data context in the Which entity record should be created/updated? field. The rule should be populated with the configured data context.



Delete Entity Record Rule

  1. Open your already existing application or start a new one.
  2. Create a new table.
  3. Add an entity to your app by clicking the Add any icon from the top of the canvas and selecting Entity.



  4. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  5. Add the following expression in the Data Context field of the main page: =Lookup(Customer, [Name, "=", "Demo"]).


  6. Add a new button control.
  7. Configure a Delete Entity Record rule for the button. Add the Customer-Main Page data context in the Which entity record should be deleted? field. The rule should delete the configured data context.



Using the New Function

  1. Open your already existing application or start a new one.
  2. Create a new table.
  3. Add an entity to your app by clicking the Add any icon from the top of the canvas and selecting Entity.



  4. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  5. Add the following expression in the Data Context field of the main page: =New(Customer).


  6. Add two textbox controls:

    • Add Data Context.Name in the the Value Binding property of the first textbox control.
    • Add Data Context.City in the the Value Binding property of the second textbox control.
  7. Add a new button control.
  8. Configure a Create/Update Entity Record rule for the button. Add the Customer data context in the Which entity record should be created/updated? field. By doing this, data is automatically bound to the fields.
  9. Remove the unused data from the fields. Make sure that you keep the data configured at step 6 in the Values to set fields.



Procedure Results

In runtime, when you add the name and city of the new customer in the two text fields and click the button, a new entry is added to the table.

Referencing Entities From Different Pages

To directly refer to a selected entity field value from a table in a different page, you need to use at least one variable.

Instead of creating variables for each field, you can use one for the Entity Id. On the second page, you can do the following:

  1. Add a container control.
  2. Configure the Data Context property of the container as follows: Lookup (Entity, [id, "=", myVariableID]).
  3. Add the needed controls inside the container and bind them to the available fields for the entity available in Data Context.

You can use the Lookup function in this case because you can treat it as an entity object. This means that you can update that entity using the Create/Update Entity Record rule on the container data context.

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.