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

 

18 REPLIES 18
Pxtavern
Helper II
Helper II

I refreshed everything to be sure but no it was made yesterday. I ran the test, there appears to be nothing in the collection, its got all the fields I am looking for though:

Pxtavern_0-1639136450892.png

 

AmDev
Super User
Super User

Would you mind sending a screen shot of the code you tried along with the error text adn with the red line below the error?

Pxtavern
Helper II
Helper II

sure,  Employee ID is actually JNumber ( which I have been taking into account) Just thought Employee ID would be clearer . 

Pxtavern_0-1639137032072.png

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

AmDev
Super User
Super User

Thanks - what control and what property has this code been applied to?

Pxtavern
Helper II
Helper II

Pxtavern_0-1639140116344.png

so the code is on the JNumber field default property 

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

Pxtavern
Helper II
Helper II

BINGO! It's working thank you so much! However, I have no idea what fixed it. Heres the one that worked:

LookUp('OCR Claimant List', EmployeeChoice_2.Selected.Email = Name.Email, JNumber)

And here is the one I was doing before...
Lookup('OCR Claimant List', EmployeeChoice_2.Selected.Email = Name.Email, JNumber)


I have no idea why that now works, the only thing I can think of is I referenced the forms sharepoint list by mistake when retyping it, and then swapped it with the OCR Claimants list and it worked. No idea why that worked 

Thank you so much for working that out 🙂 

AmDev
Super User
Super User

That's great - glad you're sorted. It was a strange one alright as you seemed to have everything as expected.

 

Please consider marking as a solution and hit the thumbs up 👍 if this was helpful in anyway.

 

Good luck with the rest of your build! ☘

Definitely helpful and the correct  solution thanks a lot for your help 😃

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (5,631)