cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shanemeisner
Helper V
Helper V

Variable not updating onvisible of Screen

On App Start I have a list of new hires for a Manager. When they click on one of the new hires I have the OnSelect = Set(varNHName, NewHires.Selected.Newhirename ) ; Navigate(Tasks)
 
On the Tasks Screen, the Gallery items are filtered using this formula: SortByColumns( Filter( managertasks, Newhirename = varNHName),"TaskOrder",Ascending)

What I am trying to do is that when that screen loads, capture how many tasks are associated for the new hire, and how many have a Status = Completed. Then, using those variables, display a progress indicator of percent complete.

My "guess"  is that the filtering of the gallery is causing an issues setting the variables, but not sure how to resolve..

I've tried multiple options for the OnVisible setting for the Tasks Screen, which all resulting with the same issue.. The variables don't update until I click a Task and then return to the Task list.

The OnVisible formulas I've tried are below:
UpdateContext({AllRows:TasksGallery});
//Set(NumberOfCompletedTasks, CountRows(Filter(AllRows.AllItems,TaskStatusVal.Text = "Completed")));
//Set(NumberOfTasks, CountRows(AllRows.AllItems));
UpdateContext( {NumberOfCompletedTasks: CountRows(Filter(TasksGallery.AllItems,TaskStatusVal.Text = "Completed"))} );
UpdateContext( {NumberOfTasks: CountRows(TasksGallery.AllItems) } );
//Set(NumberOfCompletedTasks, CountRows(Filter(TasksGallery.AllItems,TaskStatusVal.Text = "Completed")));
//Set(NumberOfTasks, CountRows(TasksGallery.AllItems))

With any of those when I first start the app and click on a new hire name, the variables come back with Zero( labels added to check) and progress bar is also at Zero:
IntialTaskScreen.png
If I click on a Task for that new hire and then return to the Task list by clicking the Cancel button( Navigate back to Tasks screen): Then the Variables update and the Progress indicator also works:

Clicktaskandreturn.png

If I click the "Return to new hires list button ( navigate to main screen), and click on a different new hire, the previous variables are "stuck" until I click on a task for that person. Only 2 items are set as completed for this user:
shouldbe2.png
and again, if I click on a task for that user and return to the Task list, the variables are correct.

Is it my Filter for my gallery causing the issue, and if so how do I "delay" the variables to update once the filter is complete?

1 ACCEPTED SOLUTION

Accepted Solutions

@PG_WorXz10  Thanks for the suggestion!! 

I ended up creating a collection as part of the Navigate button from the first screen:

Set(varNHName, NewHires.Selected.Newhirename ) ; ClearCollect(ColManTasks, Filter( managertasks, Newhirename = varNHName) ) ; Navigate(Tasks)


Then, for the OnVisible setting, I created my counts based off that Collection, rather then the filtered gallery:

UpdateContext( {NumberOfCompletedTasks: CountRows(Filter(ColManTasks, 'Task Status'.Value = "Completed"))} );
UpdateContext( {NumberOfTasks: CountRows(ColManTasks) } );

 

and now the Progress indicator and the counts change whenever the task list is shown!

Thanks again for the idea!!

View solution in original post

2 REPLIES 2
PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @shanemeisner ,

 

I would suggest. Instead of gallery if you try with the collection or DataSource binded with the gallery for countrows it might help. 

 

Set(NumberOfTasks, CountRows(Filter( DataSourceName,YourStatusColumnName= "Completed").ID));

 Below code you can put onvisible of the Screen.  

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

@PG_WorXz10  Thanks for the suggestion!! 

I ended up creating a collection as part of the Navigate button from the first screen:

Set(varNHName, NewHires.Selected.Newhirename ) ; ClearCollect(ColManTasks, Filter( managertasks, Newhirename = varNHName) ) ; Navigate(Tasks)


Then, for the OnVisible setting, I created my counts based off that Collection, rather then the filtered gallery:

UpdateContext( {NumberOfCompletedTasks: CountRows(Filter(ColManTasks, 'Task Status'.Value = "Completed"))} );
UpdateContext( {NumberOfTasks: CountRows(ColManTasks) } );

 

and now the Progress indicator and the counts change whenever the task list is shown!

Thanks again for the idea!!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,831)