Populate a Textbox using Lookup

Hi,

I’m trying to populate a TextBox’s default value based on the selected item from a Dropdown using Lookup. But for some reason the Expression is not valid.
I’ve even tried to make the expression simple by using a fixed value, here the expression I’m using:

Lookup(Employees, [Employees.FirstName, "=", "Jack"]).LastName

Thanks in advance

Hi @hgaber105

The Lookup function is not a built-in activity or method in UiPath for directly looking up values from a collection.

  1. You can use Assign activity where you set your TextBox’s default value.

  2. In the Value property of the Assign
    the expression should be
    (From row In Employees.AsEnumerable() Where row(“FirstName”).ToString().Equals(“Jack”) Select row(“LastName”).ToString()).FirstOrDefault()

  3. Make sure your Employees DataTable is in scope and contains the necessary columns (FirstName and LastName).

Hope this helps

Hello @hgaber105

Lookup(Employees, “FirstName = ‘Jack’”).LastName

Replace “Employees” with your actual DataTable variable name and adjust the column names based on your data structure.

Thanks & Cheers!!!

Hi @sanjay3 ,

I’m working on App not a Process, so I can not find the Assign activity.
Thanks and Regards

Hi @Kartheek_Battu ,

Employees is the Entity Name, EmployeesTBL is the table object name in the MainPage. In my App there is no DataTable variable.
I’ve tried the expression you shared but I got another error. I’ve replaced Employees with EmployeesTBL and still have the same error.

Thanks and Regards

@hgaber105

  1. Check Variable Existence:
  • Confirm “EmployeesTBL” is defined and exists in the correct scope.
  1. Correct Naming:
  • Replace all instances of “Employees” with “EmployeesTBL” in your expression.
  1. Data Type Match:
  • Ensure “EmployeesTBL” has the correct data type for the operation.
  1. Review Error Details:
  • Look for additional error messages in logs for more insights
1 Like

Hello @hgaber105 ,

Please have a look at video, i have covered the set default values and all

1 Like

Thanks a lot for the detailed steps in the video, it was very informative and to the point.
I have a question, what is the difference between lookup and fetch functions?

Thanks in advance.

1 Like

@hgaber105 ,

I am glad this worked for you. Lookup is legacy way of calling and Fetch is something where you can read the data and store into app variable.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.