How to use Choice Set & its Integration in UiPath Studio

What is Choice set?

A Choice Set field is used to store an enumerated list from which one or more values can be selected. A Choice Set can be used, for example, to select an expense type, a forum post category, or a certain edition of a recurring event.

A Choice Set consists of choice values that can be selected from for a field based on that choice set. The Choice Set is also made available in Studio as Enum value.
Accessing the Choice Sets

  1. On the Data Service page, click the More options menu in the upper right corner.

  2. Select Choice Sets. The Choice Sets page is displayed.


    Creating Choice Sets

  3. On the Choice Sets page, click Add Choice Set. The Create Choice Set panel is displayed.

  4. In the Display Name field enter a display name for the Choice Set.

  5. Click Add Choice.

  6. Enter a name in the new choice display name field.

  7. Repeat steps 3 and 4 for the other choices you want to add to the Choice Set.

  8. Click More details to display an additional Description field. If needed, enter a description to indicate the function of the Choice Set.

  9. Click Save.

The new Choice Set is displayed in the Choice Sets list.

I have created a TechnologyCategory Choice Set and these are the choices which added in the Choice Set.

Creating an Entity with a Choice Set Attribute in Data Services

  1. On the Entities page, click on Create New Entity.

  2. In the Display Name field enter a display name for the Entity. Lets say Technologies .

  3. Double click on the Entity and create fields for this entity.

  4. Click on Create New Field and in the Display Name field enter a display name for the field.

  5. We will create 2 fields — “Title” & “Category”.The title field will be a simple text field.

6. Create the Category field and define it as a Choice Set.

  • The Type is set to “Choice Set”
  • Under Choice Set, the selection is set to “TechnologyCategory” — this is the Choice Set we created in the steps above!
  • Make sure to enable the multiple-choice option as shown below.

7. Click Save to finish creating the Category Attribute.

Add data to the Technologies Entity

1.Click on the “Add Data” button and create the first sample record as shown below.

2. As Category field is a multiple-choice dropdown classify the technologies under two or more category labels.

3. We will create few sample records with as many different category labels as possible so that it becomes easier to verify the results from the Studio Project later.

4.Once you have completed creating the records, the Data screen must look like the one shown below.

Integration in UiPath Studio

  1. First install the UiPath.DataServices.Activities package in your project.

2. In Manage Entities , select the entity which you want to import in your project and click on save button.

3. We will now use the Query Entity Records activity to retrive the records from Data services. As we have to retrieve all the records , so we will leave Query parameter fields as blank.

The output of the query has been assigned to a local collection named TechnologyRecords that is of type IList< Technologies >
image

4. Next step is to loop through the records with a For Each activity as shown below.


image

5. The Category attribute in the Resource tab appears as a string even though we defined this field as a Choice Set when creating the entity. Therefore, using the ToString() conversion on the Category attribute will not return the expected results.
image

6.As the Category can contain more than one value,so we will add a nested For Each Activity.


image

Apply filter on Choice Sets

We will configure the Query Entity Records Activity to apply a filter on the Technology Records in Data Services. These filters will return only those Blog articles that belong to one or more Category values specified in the filter.

Here, we will pull down only those Technology records that are classified under labels “RPA” .

we can also pull down those technology records that are classified under labels “RPA” or “AI”


image

I hope you enjoyed tha article!!

Happy Automation!