cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shalem120kjh
Level: Powered On

Collect behave strangely

Hi all,

In the OnVisible property of a PowerApp screen (MyCourses Screen), I have this code:

 

Refresh(Registrations);

ClearCollect(colMyCourses, 
Filter(
Registrations, 
Employee.Email = varUser.mail, 
Priority <> 0,
Course.Id in varVisibleCourses.ID)
)

Registrations - a list in SharePoint

Employee - a Person field in that list

Priority - a Number field in that list

Course - a Lookup field in that list, looking on a different SharePoint list (Courses)

varUser - a global variable in PowerApps

varVisibleCourses - a global variable in PowerApps, which contains a subset from Courses SP list

 

In another screen of the app, I add an item to the Registrations SP list, and with the OnSuccess property of the form, I navigate to MyCourses Screen, expecting to see the newly added course. And I Do!

 

But, since the last part of the filter (Course.Id in varVisibleCourses.ID) gives a delegation warning (about the in operator), I decided to delete this part of the filter, so I'm left with a fully delegated filter:

Refresh(Registrations);

ClearCollect(colMyCourses, 
Filter(
Registrations, 
Employee.Email = varUser.mail, 
Priority <> 0)
)

Now I don't get any delegation warning, but strangely - now, after adding a course, the OnSuccess property navigates to MyCourses Screen, but the new course is not there. When I check the collection, it does not contain the new course... Only if I manually navigate away of this screen, and then navigates back to the MyCourses screen - only then, on the 2nd visit to the page, I will see the changes in the list (my new course).

 

Any idea why this is the behavior I'm seeing?

Thanks

Gil.

6 REPLIES 6
Dual Super User
Dual Super User

Re: Collect behave strangely

Hi @shalem120kjh 

 

If delegation is implemented then Refresh(Registrations) is not required since it will always delegate to the underlying data source to fetch the data

 

Employee.Email = varUser.mail, 
Priority <> 0,

These also should give you delegation warnings

Please check the app checker to ensure there are truly no delegation warnings

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

shalem120kjh
Level: Powered On

Re: Collect behave strangely

Thank you @RezaDorrani  for taking the time to read and respond.

My current code (the first snippet) does include the delegation warning, that is why I still need to Refresh(Registrations). If I can solve the problem with the collect function that does not return the most updated data, I would be happy to take off the non-delegated part and therefore also remove Refresh(Registrations).

 

Both of these - 

Employee.Email = varUser.mail, 
Priority <> 0,

do not raise delegation warnings, the app checker is clean of errors. 

I was surprised by the Employee.Email part as well.

The <> operator suppose to and does work - even by documentation for SharePoint connector.

 

Thanks again,

Gil.

Dual Super User
Dual Super User

Re: Collect behave strangely

Hi @shalem120kjh 

 

Emmployee person type column is a complex type column in PowerApps and unfortunately is not delegable

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

shalem120kjh
Level: Powered On

Re: Collect behave strangely

Hi @RezaDorrani ,

Even though they were no delegation errors, I have changed the code to:

ClearCollect(colMyCourses, 
Filter(
Registrations, 
Email = varUser.mail, 
Priority <> 0)
)

(where Email is a Single Line of Text field, which also contains the Email address of the user)
Nevertheless, when I navigate to this page I still don't see the new course right ahead, but only after navigating away and back to the screen.

Community Support Team
Community Support Team

Re: Collect behave strangely

Hi @shalem120kjh ,

I think this is mainly about the delay of updating data.

When you first navigate to this screen , the new data has not transferred to PowerApps.

I suggest you add a Timer control to add some time to update data.

For example:

Set the Timer's Duration: 10

Set the Timer's OnTimerStart: Refresh(datasource)

Set the Timer's OnTimerEnd : Navigate(Screen..,....)

 

Then, before you naviage to this screen, it will refresh the data source and wait for some moments.

Here's a doc about Timer for your reference:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/controls/control-timer

 

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
shalem120kjh
Level: Powered On

Re: Collect behave strangely

Hi @v-yutliu-msft , 

I will give it a try later, but even if it works, do you have an idea how comes when this line of code is included in the filter - the update happens immediately, and when I remove it, the update is delayed?

Course.Id in varVisibleCourses.ID

Thanks,

Gil.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,518)