cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pxtavern
Helper II
Helper II

on a form, when selecting a user from a Person field, have another field populate with their employee ID.

Hi

 

I've only been using PowerApps for a few weeks but I am having trouble figuring this one out.

 

I have a Powerapps form with a field for selecting user, and another field for inputting their employee I.D. When submitted this sends data to a SharePoint list

 

On another SharePoint list I have a person field and there Employee number stored.

 

What I want is with that original list, when a user enters their email address I want that Employee number to auto populate based on the second SharePoint list. Is that possible? Or is their an easier way.

 

Any help would be very much appreciated 

 

Pxtavern_0-1639126529203.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
AmDev
Super User
Super User

Hi @Pxtavern 

 

I just tested this scenario on my side, which involves creating new items in a destination List 1, with LookUp to List 2  for ID and have it working as follows:

 

  • List 1 = The datasource which your form is connected to and is therefore submitting the data to.
  • The 'Employee' field in your screen grab above is a person type field in List 1
  • The jNumber field is also in List 1 - this is a text field

 

  • List 2 = Your Lookup list, which also has a person field, called Name and a corresponding single line text field for the respective employee ID (called ?).

The intention is that when you select employee 'A' from the Employee dropdown in your form, jNumber for List 1 will undertake a LookUp to List 2 to seek out the email address under 'Name' that matches the selection made in your Employee dropdown control, and then return the corresponding ID field from that row of List 2 adn present that in your 'jNumber' field. To achieve this, the code is as follows in the 'Default' of the jNumber text input:

 

LookUp('List 2', EmployeeDropdown.Selected.Email = Name.Email, List2IDField)

 

Things to check:

  • 'Employee' and 'Name' Fields are both 'person fields'
  • Multi selection is disabled
  • The List 1 and List 2 ID fields are both single line text and the Column Names are different

Can you use the above to run through your own scenario and hopefully you can spot where something doesn't quite tally.

 

Thanks

View solution in original post

18 REPLIES 18
AmDev
Super User
Super User

Hi @Pxtavern 

 

Try the following in the 'Default' property of the ID control:

 

Lookup(EmployeeList, EmployeeDropdown.Selected.Value = Employee.Email, Employee ID)

 

Might need to interchange this with .Email

 

 

Pxtavern
Helper II
Helper II

Hi

 

Thanks for your quick reply. I am a little stuck so so far this all makes sense to me:

Lookup(EmployeeList, EmployeeDropdown.Selected.Value = Employee.Email, Employee ID)

 

Lookup('OCR Claimant List', EmployeeChoice_2.Selected.Email =...

 

I am stuck on that second part, what needs to go here? Employee.Email, Employee ID)

 

My Column names on the OCR Claimants list are "Name"(Person field) and Employee ID ( Text field) 

 

Are they want goes here?

AmDev
Super User
Super User

Hi @Pxtavern 

 

Try: Lookup('OCR Claimant List', EmployeeChoice_2.Selected.Email = Name.Email, Employee ID)

 

You are essentially looking up your list for the record/row where the email in your drop down matches the email in your name column and once that's found, produce the result based on you Employee ID column)

 

Hope this clarifies

Pxtavern
Helper II
Helper II

I thought that was the case, it comes up with an error, so as far as I can tell it should read as:

Lookup('OCR Claimant List', EmployeeChoice_2.Selected.Email = Name.email, Employee id)

 

but when typing in the = name.email it isn't auto looking up the fields from the SharePoint list.

 

Any idea?

AmDev
Super User
Super User

Can you provide details of the error?

 

Also, make sure the capitalisation matches (i.e. it should be  = Name.Email)

 

If this is still failing, can you provide a screen shot of the edit column settings for your 'Name' Column?

Pxtavern
Helper II
Helper II

So Name.Email comes up with - Invalid use of "." and if I fill out the whole code it says on the error pop up:

Pxtavern_0-1639132892025.png

Which as far as I can tell means it isn't finding those columns, although it is 100% the correct spelling/ capitals as I have copied from the SharePoint URL for that Column.

 

P.S Thank you for your help so far 

AmDev
Super User
Super User

Thanks - Can you go to the Name column in your sharepoint list, go to 'column settings\edit\expand more options' and take a screen shot?

Pxtavern
Helper II
Helper II

Pxtavern_0-1639135117873.pngPxtavern_1-1639135167323.png

Heres the details 

AmDev
Super User
Super User

Is this potentially a new column you have added recently while you had the app open and you just need to refresh the dataset? 

 

If not, Can you do a ClearCollect(colTEST, First(YourDataSource)) and then go to view\collections and try to find the name column and open the nested table to make sure all the person attributes are there?

 

Thanks

 

 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,895)