cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rajesh6
Regular Visitor

how to work with seach function with lookup column

Hi Team,

 

I am working on the search box with gallery, when user search the employee and department that display the gallery but i am getting error message like "wrong column type, expects text type" department is a lookup column(its not a dropdown). data is coming from the crm system.

 

any alternative way to achieve the lookup column with search functionality in power apps

here is the example code

If(
    IsBlank(SearchBox.Text),
   TestColl1,
    Search(TestColl1,
        SearchBox.Text,
         "employee","department"
    )
)
1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@rajesh6 

Consider changing your Formula to the following:

Search(
    AddColumns(TestColl1, "lDepartment", department.Title)
    SearchBox.Text,
    "employee", "lDepartment"
 )

Replace .Title above with whatever value you have in the department record that you want to search on.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

3 REPLIES 3
RandyHayes
Super User III
Super User III

@rajesh6 

Consider changing your Formula to the following:

Search(
    AddColumns(TestColl1, "lDepartment", department.Title)
    SearchBox.Text,
    "employee", "lDepartment"
 )

Replace .Title above with whatever value you have in the department record that you want to search on.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

Eelman
Super User
Super User

@rajesh6 

Sounds like you are using CDS as your data source? If so, I'm not that familiar with it but the following troubleshooting generally works when using SharePoint as a data source

 

try changing ... "department" ... to 

- ... "department".Value ... or

- ... "department".Name ...

 

Use the dot operator with PowerApps Intellisense to guide you if 'Value' or 'Name' do not work. 

 

Beyond this, you may need to find someone who works with CDS because it does have some little quirks to it when using it in PowerApps. I'll tag someone I think maybe able to assist

 

@PowerAddict ?

Thanks @Eelman!

 

@rajesh6, as far as I understand, both Department and Employee are lookup fields, is that correct? If so, do you want to search by employee's first or full name? If so, what is the relevant field on the Employee entity? Similar questions for Department as well if that's a lookup field. Do you want to search by department name? If so, what is the name field on the Department entity called? 

 

Let me know the answers to these questions and we should be able to solve this. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Microsoft Business Applications MVP

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,894)