cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Checking if a Person is already addet do a field in SharePoint

Hi,

 

I have a people column in SharePoint where I can add multiple people to a field. Now I want to check in PowerApps whether a person is already in this field. If not, the person is added to the field (already coded).

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate II
Advocate II

Re: Checking if a Person is already addet do a field in SharePoint

Hi @Anonymous,

no solution above worked out for me. So now i changed my multiselect-person-column to another Sharepoint list where i save the person with the ID of the field as the title. This works perfect for me even if its not a clean solution.

Best regards.

View solution in original post

9 REPLIES 9
Highlighted
Impactful Individual
Impactful Individual

Re: Checking if a Person is already addet do a field in SharePoint

Hey @jhumml 

 

You could just do a Filter search on the table to see if this person exists and see if the seqrch is empty. The IsEmpty() will return true if the Filter search has no results to return, meaning that this person does not exist in the table. The if function will then on 'true' execute the code to add the person to the table. If return false, meaning person does existm do nothing or add code to take other measures.

 

If( IsEmpty( Filter( DATASOURCE_TABLE, person = vPersonToAdd)), ADD PERSON CODE ) )

I hope this helps

Highlighted
Advocate II
Advocate II

Re: Checking if a Person is already addet do a field in SharePoint

Good idea, I think that's the right approach,

but my next problem is that the person in the column and the User() are different argument types.

IsEmpty(Filter(DATASOURCE_TABLE, columnName = User()))

It gives me the error: "Invalid argument type"

even if I write

IsEmpty(Filter(DATASOURCE_TABLE, columnName.Email = User().Email))))

it gives me the same error.

I think that's because in columName there could be more than one person, therefore it's a different argument type. but idk.

Highlighted
Impactful Individual
Impactful Individual

Re: Checking if a Person is already addet do a field in SharePoint

I'm not sure how your table is constructed. Do you have a column 'Name' in which records get stored for each added person? If so, you should do the next:

 

IsEmpty(Filter(DATASOURCE_TABLE, personName = User().FullName))

'DATASOURCE_TABLE' is the source you need to search in. 'personName' is the title of the column in which you can only store the name of the user, and not the object User. When you call User(), you'll call an object of the user that contains different variables. But if you want to search on the name of the user, you should get the proper variable from the object: thus you need to extract the FullName from the User. 

Highlighted
Advocate II
Advocate II

Re: Checking if a Person is already addet do a field in SharePoint

My column type is "Person or Group" and I have checked the "Allow multiple selection" box.
I tried to write each person's name in a text column using flow. But it turned out to be a more difficult problem.

I just want to check if a Person is already present in a multiselect Person Field.
I have the feeling that the rest of Microsoft can't handle multiselect person columns. 

Highlighted
Impactful Individual
Impactful Individual

Re: Checking if a Person is already addet do a field in SharePoint

Okay, so just to get clear. You have a table that contains a column "Person or Group". In every record there is a field for this column where you can add one or more persons, right?

 

So now you have a name of a person, and you want to check if it already exists in that field of a certain record?

 

You also want to be able to display all of the names of that field of a certain record?

Highlighted
Advocate II
Advocate II

Re: Checking if a Person is already addet do a field in SharePoint


@SkiDK wrote:

Okay, so just to get clear. You have a table that contains a column "Person or Group". In every record there is a field for this column where you can add one or more persons, right?

Exactly, or leave it empty

 


So now you have a name of a person, and you want to check if it already exists in that field of a certain record?


Basically the user who uses my app has to add himself by pressing a button, but first i have to check if he is already in that field so he doesnt add himself twice. SharePoint itself doesnt let that happen but i have other code which needs that. I thought this would be the easiest way but i've been trying to change my code for 3 hours now.

 

You also want to be able to display all of the names of that field of a certain record?


Yes

 

Dual Super User III
Dual Super User III

Re: Checking if a Person is already addet do a field in SharePoint

Hi @jhumml 

 

In reference to this other thread posted by you:
 
If you do not want current user to be added again, you can modify your expression as:
 
ClearCollect(ExistingUsers,If(!(User().Email in LookUp(UserList,Title = "test").PersonField.Email),Table({'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims:"i:0#.f|membership|" & User().Email,
    Department:"",
   DisplayName:User().FullName,
         Email:User().Email,
      JobTitle:"",
       Picture:""
   })),LookUp(SPList,Title = "test").PersonField);
Patch(SPListName,LookUp(SPListName,Title = "test"),{PersonField:ExistingUsers})
 
This expression could be modified if you donot want to use the current user in this case, you just need to update the If condition.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Highlighted
Anonymous
Not applicable

Re: Checking if a Person is already addet do a field in SharePoint

Hi @jhumml how are you progressing with this?

 

@Anonymous 

Highlighted
Advocate II
Advocate II

Re: Checking if a Person is already addet do a field in SharePoint

Hi @Anonymous,

no solution above worked out for me. So now i changed my multiselect-person-column to another Sharepoint list where i save the person with the ID of the field as the title. This works perfect for me even if its not a clean solution.

Best regards.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,092)