cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Magnifica-p
Level: Powered On

Filter Office 365 Users by user information

Hello i am building an employee search app.

 

there i have a view where i display only 4 result but if my variable is true, i want to display all search results.

I have a workaround for it, but my code is very long und "dirty" - is there any way to make this a little bit sleeker?

 

I am filtering the data

- DisplayName

- GivinName

- Surname

- City

- JobTitle

- MailNickname

by what the user enters in the "text input field" (Txt_Suchfeld_4)

 

If(
    varMitarbeiterresults = true;
Filter( 'Office365-Benutzer'.SearchUser(); Txt_Suchfeld_4.Text in DisplayName ||
Txt_Suchfeld_4.Text in City ||
Txt_Suchfeld_4.Text in Department ||
Txt_Suchfeld_4.Text in JobTitle ||
Txt_Suchfeld_4.Text in GivenName ||
Txt_Suchfeld_4.Text in Surname ||
Txt_Suchfeld_4.Text in MailNickname
); FirstN( Filter( 'Office365-Benutzer'.SearchUser(); Txt_Suchfeld_4.Text in DisplayName ||
Txt_Suchfeld_4.Text in City ||
Txt_Suchfeld_4.Text in Department ||
Txt_Suchfeld_4.Text in JobTitle ||
Txt_Suchfeld_4.Text in GivenName ||
Txt_Suchfeld_4.Text in Surname ||
Txt_Suchfeld_4.Text in MailNickname
); 4) )

This code is very long, and redundant. Is there a way to shorten it?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Filter Office 365 Users by user information

Hi @Magnifica-p 

 

Yes, you can shorten your code by using the Search function. Please use the below expression:
 
If(
    varMitarbeiterresults = true;
            Search('Office365-Benutzer'.SearchUser();
                 Txt_Suchfeld_4.Text; "DisplayName";"City";"Department";"JobTitle";"GivenName";"Surname";"MailNickname"
            );
           FirstN(
            Search('Office365-Benutzer'.SearchUser();
                Txt_Suchfeld_4.Text; "DisplayName";"City";"Department";"JobTitle";"GivenName";"Surname";"MailNickname"
            );4)
)
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!
5 REPLIES 5
Super User
Super User

Re: Filter Office 365 Users by user information

Hi @Magnifica-p 

 

Yes, you can shorten your code by using the Search function. Please use the below expression:
 
If(
    varMitarbeiterresults = true;
            Search('Office365-Benutzer'.SearchUser();
                 Txt_Suchfeld_4.Text; "DisplayName";"City";"Department";"JobTitle";"GivenName";"Surname";"MailNickname"
            );
           FirstN(
            Search('Office365-Benutzer'.SearchUser();
                Txt_Suchfeld_4.Text; "DisplayName";"City";"Department";"JobTitle";"GivenName";"Surname";"MailNickname"
            );4)
)
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!
Magnifica-p
Level: Powered On

Re: Filter Office 365 Users by user information

Hi @yashag2255 

That worked perfectly - Thank you very much!

Magnifica-p
Level: Powered On

Re: Filter Office 365 Users by user information

@yashag2255  one more question, i a similar issue with another gallery of projects.

Here i want to do the same thing - if my variable is true, all items displayed if not only 4.

Again i am filtering by Title, Client.Value (Lookup Field), User.DisplayName (People Picker Field (multiple)) etc..

can i shorten the code here as well? I tried it but it gives an error.

 

If(varProjectresult = true;
    Filter(Projekte; 
            Txt_Suchfeld_4.Text in Kunde.Value || 
            Txt_Suchfeld_4.Text in Titel || 
            Txt_Suchfeld_4.Text in Mitarbeiter.DisplayName || 
            Txt_Suchfeld_4.Text in Mitarbeiter.JobTitle || 
            Txt_Suchfeld_4.Text in Mitarbeiter.Department
    );

    FirstN(
        Filter(
            Projekte; 
                Txt_Suchfeld_4.Text in Kunde.Value || 
                Txt_Suchfeld_4.Text in Titel || 
                Txt_Suchfeld_4.Text in Mitarbeiter.DisplayName || 
                Txt_Suchfeld_4.Text in Mitarbeiter.JobTitle || 
                Txt_Suchfeld_4.Text in Mitarbeiter.Department ||
  Txt_Suchfeld_4.Text in Mitarbeiter.Department || ); 4 ) )

I tried it with Search this way but it didnt work

If(varProjectresults = true;
	Search(Projekte;
		Txt_Suchfeld_4.Text; 
			"Titel";"Kunde.Value";"Mitarbeiter.DisplayName";"Mitarbeiter.JobTitle";"Mitarbeiter.Department"
			);
	FirstN(
		Search(Projekte; 
		Txt_Suchfeld_4.Text; 
			"Titel";"Kunde.Value";"Mitarbeiter.DisplayName";"Mitarbeiter.JobTitle";"Mitarbeiter.Department"
				);
			4)
)
 

 

Super User
Super User

Re: Filter Office 365 Users by user information

@Magnifica-p 

 

Can you please a bit more information about the error that you are getting? Please share a screenshot.
Magnifica-p
Level: Powered On

Re: Filter Office 365 Users by user information

hi @yashag2255 

I have this part of the code running

If(varProjectsresults = true; 
Search(
Projekte; Txt_Suchfeld_4.Text; "Title");
FirstN(
Search(
Projekte; Txt_Suchfeld_4.Text; "Title");
4)
)

error.PNG

But when I try to filter/search by the Field "Kunde" which is a look up field from another sharepoint list, it says "Search indicates invalid value" and "wrong column type. The type 'text' is expected"

if I change "Kunde" to "Kunde.value" it says it doesnt excist. 

 

... for now i have this code running:

If(varProjectresults = true;
	Filter(Projekte;
		Txt_Suchfeld_4.Text in Kunde.Value || Txt_Suchfeld_4.Text in Titel || Txt_Suchfeld_4.Text in Mitarbeiter.DisplayName || Txt_Suchfeld_4.Text in Mitarbeiter.JobTitle || Txt_Suchfeld_4.Text in Mitarbeiter.Department
			);
	FirstN(
		Filter(Projekte; 
		Txt_Suchfeld_4.Text in Kunde.Value || Txt_Suchfeld_4.Text in Titel || Txt_Suchfeld_4.Text in Mitarbeiter.DisplayName || Txt_Suchfeld_4.Text in Mitarbeiter.JobTitle || Txt_Suchfeld_4.Text in Mitarbeiter.Department
				);
			4)
)