Subscribe

UiPath Apps

The UiPath Apps Guide

Using Data Context

Background information

For more information related to entities, see the following guides:

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 Add Any iconAdd Any icon icon from the top of the canvas and selecting Entity.
664664
  1. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  2. Add the following expression in the Data Context field of the main page: =Lookup(Customer, [Name, "=", "Demo"]).
689689
  1. Add a new textbox control.
  2. 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.
18491849

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 Add Any iconAdd Any icon icon from the top of the canvas and selecting Entity.
664664
  1. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  2. Add the following expression in the Data Context field of the main page: =Lookup(Customer, [Name, "=", "Demo"]).
689689
  1. Add a new button control.
  2. 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.
491491

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 Add Any iconAdd Any icon icon from the top of the canvas and selecting Entity.
664664
  1. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  2. Add the following expression in the Data Context field of the main page: =Lookup(Customer, [Name, "=", "Demo"]).
689689
  1. Add a new button control.
  2. 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.
480480

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 Add Any iconAdd Any icon icon from the top of the canvas and selecting Entity.
664664
  1. Bind the newly-added entity to the table by adding it in the Data Source field of the table.
  2. Add the following expression in the Data Context field of the main page: =New(Customer).
689689
  1. 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.
  2. Add a new button control.
  3. 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.
  4. Remove the unused data from the fields. Make sure that you keep the data configured at step 6 in the Values to set fields.
394394

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.

Updated 2 months ago

Using Data Context


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.