Join the Team Forms community

N
D
M
T
T

SharePoint Data Source People Picker Field Issues

Updated 16 hours ago

Hi,

Our SharePoint data source list uses people picker columns. When trying to access the data in those fields it just returns the "LookupId" of those fields instead of the name.

Is there a way to access other information than just the LookupId saved in those fields?

Marked as solution

Hi Damon,

Unfortunately, SharePoint list lookup fields are currently not well supported. Lookup columns (like person columns) will only return the lookup Id. There is unfortunately no simple no code way to get the person's name from the lookup id.


Would what you are trying to achieve be solved with the user component? or do you require the user component to have additional functionality like the option to filter the list of users?

View full solution
E
D
A
1 comment·9 replies

Hi Damon,

Unfortunately, SharePoint list lookup fields are currently not well supported. Lookup columns (like person columns) will only return the lookup Id. There is unfortunately no simple no code way to get the person's name from the lookup id.


Would what you are trying to achieve be solved with the user component? or do you require the user component to have additional functionality like the option to filter the list of users?

Hi Erin,

The user component doesn't work for us as half of our employees don't have accounts, so we have to rely on the employee name list we have in a SharePoint list.

It's okay if we need to code. We just need to be able to get the name and display it inside the form in real time to the user.

Can you point me in the right direction?


I could be wrong, but my understanding is that Person field in SharePoint only shows users who have accounts in your AD. Is that not the case?

Hi Damon,

I'm happy to share an option, however would you mind confirming if @Anthony Phan's suggestion is correct first? If the Person field only allows users (including guests) of your AD then the user component may solve the issue.

You may find when you add a person who is external to your organization in a "Person" column it in implicitly adding them to you Microsoft Entra, in which case they may actually appear in the user component.

It's also worth noting that when the user component is configured to Team Members it sets up a data source to your SharePoints "User Information List". This list is what your "Person Column" uses to lookup people to display in that column. This means that anyone who appears in your person column will actually also be available in the user component (when configured to Team Members).

@Anthony Phan you are completely right. To clarify, here is how we are using the list and why this is a problem: the SharePoint list holds the names and information of all our employees, 200 with Microsoft accounts, 200 without. One of those columns holds the information of their line manager, this is the people field I'm referring to. These managers all have accounts, so we can use the people field.

Now in the form we made, the SharePoint field let's the responders pick the employee and then they need to be able to see who their manager is, but when trying to pull the data from the manager column it only returns the LookupId.


@Erin Dwyer I did read about the User Information List you mentioned when I was researching the LookupId, but I cannot find a way to access that list as a data source inside Team Forms to be able to relate the LookupId to the actual person. Is there a way?

Thanks for the additional context! It sounds like ultimately you need to resolve the manager.

Here's how I would approach solving the issue:

  1. Drag and drop the SharePoint data component into your form and configure it to show the employee names

  2. Drag and drop a text field into your form to display the corresponding manager. This filed will be a calculated field that does a lookup on the user information list.

  3. Navigate to the "Datasource" screen to check that you have a system managed data source called "Team Members" and click the "..." icon followed by "Data Source Id". Note down this id to use in the JavaScript expression later.

    Note that this data-source gets automatically created by Team Forms if you have previously used the user component.

    Screen shot of Team Forms team members data-source
  4. In the calculated value of your textfield use the following JavaScript to lookup the users name based on the lookup Id. You will need to adapt this code to suite your specific form and data-source Ids.

JavaScript
async function lookupValue(){
    const userInfomationList = await tf.getDataSource('replace_with_team_members_data_source_id')
    const user = userInfomationList.find(user => user?.id === data.employee.ManagerLookupId)
    instance.setValue(user?.Title || '')
} 

lookupValue()


Here is an example of the outcome:

Thank you very much for the clear instructions, Erin!

I did everything as you said, but sadly the ManagerLookupId from the SharePoint data component doesn't return to the correct person when looking it up with your code in the Team Members list.


The user information list is unique to each SharePoint site. This means you need to use the User information list from the same SharePoint site as the employee list. Can you confirm that is the case?

If your employee list is hosted on a different team/site to your forms this does not align with Team Forms best practise. This an create many many issues like the one you may be experiencing here.

Hi Erin,

you are completely right! Once we moved the user list to the same group site as Team Forms is using, your code works like a charm and the problem was resolved!


Thank you very much!