Hi everyone,
I was facing one issue regarding run time data loading. To give you guys a better context I will explain the problem with the following example
Basically I have built Canvas App that users can use to raise request and this application has 4 roles: User, Manager, Admin and Infra. For Admin and Infra role I ham maintaining two separate SharePoint list named AdminList_VManagement and InfraTeam_VM bot these list have a Title column and Person type column
And for Manager details: I am referencing another list ManagerList_SM
(The above list is just used for referring a user's reporting manager)
In Power Apps to determine the Role I have designed the following expression:
Set(
CurrentUserRole,
If(
//Team Center Admin
CountRows(Filter(Admins,Administrator.Email = User().Email)) > 0, "Admin",
//Infra Team
CountRows(Filter(InfraTeam_VM,Member.Email = User().Email)) > 0, "Infra",
//Manager
CountRows(Filter(VMRequest,Manager = User().Email)) > 0, "Manager",
"User"
)
);
I have a request Overview screen that shows the request created (I have also added a constraint that user should only see the request that they have created
It looks something like: (All the request that you see are the one's that I have created )
On Gallery's Items property:
If(
varSearchClicked && !IsBlank(SearchInput2_1.Value),
Search(
SortByColumns(
Filter(
VMRequest,
(CurrentUserRole = "Admin" && (Status.Value = "In-Progress" || Status.Value = "VM-Granted" || Status.Value = "VM-Provisioning")) ||
(CurrentUserRole = "Manager" && Status.Value = "In-Review" && Manager = User().Email) ||
(CurrentUserRole = "Infra" && Status.Value = "VM-Provisioning") ||
(CurrentUserRole = "User" && Email = User().Email),
// Apply status filter only if varStatusSelected is not blank
If(!IsBlank(varStatusSelected), Status.Value = varStatusSelected, true)
),
"Created",
varSortOrder
),
SearchInput2_1.Value,
Title
),
// Default view if no search input or varSearchClicked is false
SortByColumns(
Filter(
VMRequest,
(CurrentUserRole = "Admin" && (Status.Value = "In-Progress" || Status.Value = "VM-Granted" || Status.Value = "VM-Provisioning")) ||
(CurrentUserRole = "Manager" && Status.Value = "In-Review" && Manager = User().Email) ||
(CurrentUserRole = "Infra" && Status.Value = "VM-Provisioning") ||
(CurrentUserRole = "User" && Email = User().Email),
// Apply status filter if varStatusSelected is not blank
If(!IsBlank(varStatusSelected), Status.Value = varStatusSelected, true)
),
"Created",
varSortOrder
)
)
And for the title text for different role: the text changes like for user the title text of the screen is: Request Overview ; for Manager role it is: Manager Dashboard for Request Overview so on the Text property I have set the following expression
//For Screen Title Text
If(
CurrentUserRole = "User",
"Request Overview",
//For Manager and other roles:
If(
CurrentUserRole = "Manager",
"Manager View for: " & "Request Overview",
//For Admin and Infra:
If(
CurrentUserRole = "Admin",
"Admin View for: " & "Request Overview",
"Infra View for: " & "Request Overview"
)
)
)
So recently I have observed that for other roles like Manager/Admin (all the changes were saved and published) sometimes the request Overview screen shows title: Infra View and the items in gallery is Blank, but after refreshing the page 1-2 times then it shows the data as expected. So to cross check I checked in the code (Edit mode) for the respective members in Manager and Admin role the value in currentUserRole was been set properly.
The below image is of Admin role: In Run Mode
To cross-check I asked the Admin role in the edit mode if the value in variable is been set properly or not and it was as expected:
And after refreshing the page 2-3 times then the data was shown properly as per the respective user role, to better understand this you can have a look at the GIF, you can get a clear picture of what I am referring to
I am not sure what is the issue at start it was working fine with no issues but since last week I came across this issue, I have not made any changes in my App On-start nor on Items property of the gallery that displays the request.
The gallery displays request from 'VMRequest' which is a SharePoint list that stores all the request it looks like: