I used to have a hierarchy in my OnStart that was handling expanding and retracting my Tasks based on SharePoint Columns.
My app was getting slower and slower as time passed on.
My code snippets are here:
ClearCollect(
colTasks,
AddColumns(MYDATALIST,
"Show", ThisRecord.TaskLvl = 0,
"Expanded", false,
"TaskHierarchy",If(ThisRecord.TaskLvl= 0, "0", If(ThisRecord.TaskLvl= 1, With({localOuterRecord: ThisRecord}, LookUp(MYDATALIST, Id=localOuterRecord.ParentId).TaskNo & "." & Text(localOuterRecord.TaskNo, "000")))),
"ProjectCreationDate", If(ThisRecord.TaskLvl= 0, Oprettet, If(ThisRecord.TaskLvl= 1, With({localOuterRecord: ThisRecord}, LookUp(MYDATALIST, Id=localOuterRecord.ParentId).Oprettet)))
)
);
With(
{localColTasks: colTasks},
UpdateIf(
colTasks As ThisTask,
ThisTask.TaskLvl=2,
{
TaskHierarchy: LookUp(localColTasks, Id=ThisTask.ParentId).TaskHierarchy & "." & Text(ThisTask.TaskNo, "000"),
ProjectCreationDate: LookUp(localColTasks, Id=ThisTask.ParentId).ProjectCreationDate
} //With({localOuterRecord: ThisRecord},LookUp(localColTasks, Id=OuterColTask.ParentId).TaskHierarchy & "." & OuterColTask.TaskNo)}
)
)
Then in my gallery i had an icon that was handling the Expanding and retracting of my Tasks. Code is here:
Select(Parent);
With({localItem: ThisItem},
UpdateIf(
colTasks,
// Show childTasks of current task
!localItem.Expanded && ParentId = localItem.Id && TaskLvl <> 0,
{Show: true},
// Hide Hierarchy of current task
localItem.Expanded && (localItem.ProjectId = ThisRecord.ProjectId) && !(ThisRecord.TaskLvl = 0) && (localItem.TaskHierarchy in ThisRecord.TaskHierarchy) && Id <> localItem.Id,
{Show: false, Expanded: false},
// change Expanded field for this task
Id = localItem.Id,
{Expanded: !localItem.Expanded}
);
finally i have a gallery that has some code in its Items:
SortByColumns(Filter(
colTasks As OuterTask,
// Never show rejected tasks..
OuterTask.Status.Value <> "Rejected",
(IsBlank(OuterTask.PrimaryAssignee) && ("Ikke tildelt" in Filter(colAssignees, Active).DisplayNameAssignee))
// Always show if a childtask is to be shown
|| !IsBlank(LookUp(colTasks,
// Childtask is a Childtask - ALSO FINDS ITSELF!
OuterTask.ProjectId = ProjectId && OuterTask.TaskHierarchy in TaskHierarchy
// ChildTask has its Primary assignee set to Active in colAssignees.
&& !IsBlank(LookUp(colAssignees, Active && If(IsBlank(PrimaryAssignee), DisplayNameAssignee = "Ikke tildelt", DisplayNameAssignee = PrimaryAssignee.DisplayName)))
// Should not take completed childtasks into account if toggle is off.
&& If(toggle_ShowCompletedTasks.Value, !(Status.Value = "Completed") || ((Status.Value = "Completed") && CompletedDateTime > (Today()-Slider_ShowCompletedTasksXDaysBackInTime.Value)), !(Status.Value = "Completed"))
)),
// Show completed tasks
If(toggle_ShowCompletedTasks.Value, !(OuterTask.Status.Value = "Completed") || ((OuterTask.Status.Value = "Completed") && OuterTask.CompletedDateTime > (Today()-Slider_ShowCompletedTasksXDaysBackInTime.Value)), OuterTask.Status.Value <> "Completed"),
// Backlog and TaskTypes
!IsBlank(LookUp(colTasks As ProjectTask,
// Projekt is shown
(ProjectTask.TaskLvl = 0)
&& ProjectTask.Show
&& (OuterTask.ProjectId = ProjectTask.ProjectId)
&& If(Dd_ChoosePrio.Selected.Value = "Alle", true, ProjectTask.Prioritet = Dd_ChoosePrio.Selected.Value)
&& If(Dd_ChoosePrio_TaskType.Selected.Value = "Alle", true, ProjectTask.TaskType = Dd_ChoosePrio_TaskType.Selected.Value)
// Check if project is in backlog according to Toggle backlog
&& If(toggle_ShowBacklog.Value,
//
((ProjectTask.Status.Value = "Backlog") || IsBlank(ProjectTask.Status.Value))
,
((ProjectTask.Status.Value <> "Backlog") && !IsBlank(ProjectTask.Status.Value))
)
// Show if projectTaskType is ON or projectTaskType is blank
&&
(IsBlank(ProjectTask.TaskType) || (ProjectTask.TaskType in Filter(colTaskTypes, ShowTaskType = true).TaskTypeLongName))
))
,
!IsBlank(varUserConfig) && Text(OuterTask.TeamName) = varUserConfig.TeamName,
OuterTask.Show
),
If(toggle_ShowBacklog, "ProjectCreationDate", "ProjectName"), SortOrder.Ascending,
"TaskHierarchy", SortOrder.Ascending
)So in the filter i am choosing not to show my rejected tasks. i am only filtering on active tasks and i have a toggle that shows me backlog tasks.
And this Triumvirate used to work pretty good but i have been noticing an increase in the load time in the app. it takes about a minute (give or take) to load the app now.
I have considered moving all this to the StartScreen property of the OnStart BUT that would "just" be sweeping the problem under a rug as i would still have the users wait for all this to load in etc...
Is there not an easier way of doing this where my app doesnt have to suffer from long load times?
i have even made 3 new columns in my Data list called TaskLevel0, TaskLevel1 and TaskLevel2.
All i need to do is to somehow figure out how i can filter my gallery where it shows the correct levels attached to each other.
Here is a sample of how my data looks with the "old" code.
Here is how my SharePoint list
So based on all of the above is there a faster method where i can build and tell the gallery how the hierarchy needs to be structured based on my data.

Report
All responses (
Answers (