Hi,
I have a gallery view in a powerapp that show some records created by different users. I have received a request to only show the records that the current user created. No problem in that BUT I have one user that should be able to see the records for all users. For that I wanted to use an OR in the filter, but I cannot get it to work.
The filter on current user that works:
SortByColumns(Filter([@'Kantineformular Liste2']; Udfyldt_Af_Email=User().Email && StartsWith(Title; TextSearchBox1.Text)); "Created"; If(SortDescending1; Ascending;Descending ))
The one with the extra email added to see all(doesn't work)
SortByColumns(Filter([@'Kantineformular Liste2']; (Udfyldt_Af_Email=User().Email Or User().Email="someuser@company.com") && StartsWith(Title; TextSearchBox1.Text)); "Created"; If(SortDescending1; Ascending;Descending ))
I tried with different formatting but alas.
Hope someone can help:)
Solved! Go to Solution.
Hi @DSKJ, If your second user must see all records, why you use a filter for this user?. Before filter you can validate what user is and use a filter or not.
The formula with the extra email doesn't work because User().Email is not a column, you must use a column name to filter a table.
Based on the help I got I now have it working. Maybe it's crude and could be optimized but it works and my dataset is very small 🙂
Here's an anonymized version to help other people:
If(User().Email="someuser@comecompany.com";
SortByColumns(Filter([@'Kantineformular Liste2']; StartsWith(Title; TextSearchBox1.Text)); "Created"; If(SortDescending1; Ascending;Descending ))
;
SortByColumns(Filter([@'Kantineformular Liste2']; Created_By_Email=User().Email ); "Created"; If(SortDescending1; Ascending;Descending ))
)
Hi,
Can you please try wrapping Email id's in Lower function
Make sure you empty the default property of search text box
SortByColumns(Filter([@'Kantineformular Liste2']; (Lower(Udfyldt_Af_Email)=Lower(User().Email) Or Lower(User().Email)=Lower("someuser@company.com")) && StartsWith(Title; TextSearchBox1.Text)); "Created"; If(SortDescending1; Ascending;Descending ))
Hi @DSKJ ,
I have made a slight modification to the syntax and added a condition where the TextSearchBox1 is blank:
SortByColumns(
Filter(
[@'Kantineformular Liste2'];
Udfyldt_Af_Email=User().Email Or User().Email="someuser@company.com",
IsBlank(TextSearchBox1) Or StartsWith(Title; TextSearchBox1.Text)
);
"Created";
If(
SortDescending1;
Ascending;
Descending
)
)
Hi @DSKJ, If your second user must see all records, why you use a filter for this user?. Before filter you can validate what user is and use a filter or not.
The formula with the extra email doesn't work because User().Email is not a column, you must use a column name to filter a table.
Thank you for that information - I didn't know it could be done that way.
And also thank you for the information about the column issue
Based on the help I got I now have it working. Maybe it's crude and could be optimized but it works and my dataset is very small 🙂
Here's an anonymized version to help other people:
If(User().Email="someuser@comecompany.com";
SortByColumns(Filter([@'Kantineformular Liste2']; StartsWith(Title; TextSearchBox1.Text)); "Created"; If(SortDescending1; Ascending;Descending ))
;
SortByColumns(Filter([@'Kantineformular Liste2']; Created_By_Email=User().Email ); "Created"; If(SortDescending1; Ascending;Descending ))
)