cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

ClearCollect OnVisible doesn't seem to be working

I'm trying to load some data from a DB into a collection. The following code is specified on the OnVisible parameter of the page.

 

ClearCollect(
    actual_supplierID,
    ForAll(
        Filter(
            '[dbo].[OldSuppliers]',
            SourcingRecordId = Record.Id
        ).Identifier,
        LookUp(
            '[cube_GroupSourcing].[Supplier]',
            Supplier_x0020_Code = Identifier
        )
    )
);

The actual_supplierID collection returns empty the first time I trigger OnVisible. However, if I go to a different screen and reload the page, once again triggering OnVisible,  the collection this time will actually have the data within it. Could somebody perhaps try to explain what's causing this behaviour ?

 

The [dbo].[OldSuppliers] DB has 547 rows but we've set the delegate limit to 2000. 

 

Any help is greatly appreciated.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Dual Super User II
Dual Super User II

Re: ClearCollect OnVisible doesn't seem to be working

If its not the first page in the app then I would move the ClearCollect statement to where the navigation is that loads the page. I think OnVisible has been changed to be an Async process so there is no guarantee that what you do there will finish before the page completes loading.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Highlighted
Community Support
Community Support

Re: ClearCollect OnVisible doesn't seem to be working

Hi @Anonymous ,

Which screen's OnVisible property is set to the ClearCollect formula you mentioned above?

 

The OnVisible property of current screen would be fired only when you navigate to the current screen from another screen. Please make sure you have set the OnVisible property of the screen (where you need to use the actual_supplierID collection) to the ClearCollect formula you used.

 

Based on the issue that you mentioned, I have made a test on my side, the OnVisible property of the screen fires well. Please also consider modify your formula as below:

Clear(actual_supplierID);
ForAll( Filter( '[dbo].[OldSuppliers]', SourcingRecordId = Record.Id ).Identifier, Colelct(actual_supplierID, LookUp('[cube_GroupSourcing].[Supplier]', Supplier_x0020_Code = Identifier)) )

In addition, you could also consider set the OnHidden property of the screen where you set the Record variable to following formula (instead of OnVisible property of target screen):

ClearCollect(
    actual_supplierID,
    ForAll(
        Filter(
            '[dbo].[OldSuppliers]',
            SourcingRecordId = Record.Id
        ).Identifier,
        LookUp(
            '[cube_GroupSourcing].[Supplier]',
            Supplier_x0020_Code = Identifier
        )
    )
);

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Highlighted
Dual Super User II
Dual Super User II

Re: ClearCollect OnVisible doesn't seem to be working

If the OnVisible you are using is on the first screen in the App then you would be better off putting it in the App OnStart and turning off the feature lets the screen load before OnStart finishes.  I think what you are seeing is that the collection loads in the background but doesn't finish until after the page loads.  So if you go away and come back then the collection is already there.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Anonymous
Not applicable

Re: ClearCollect OnVisible doesn't seem to be working

Thanks for the quick reply!

The page isn't the first page in the app and it wouldn't be possible to make it so.

The App loads data from the DB which is saved in previous pages of the Application. And yes I've checked to make sure that the data is actually in the DB at the point in time in which OnVisible is triggered.

Highlighted
Dual Super User II
Dual Super User II

Re: ClearCollect OnVisible doesn't seem to be working

If its not the first page in the app then I would move the ClearCollect statement to where the navigation is that loads the page. I think OnVisible has been changed to be an Async process so there is no guarantee that what you do there will finish before the page completes loading.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Highlighted
Anonymous
Not applicable

Re: ClearCollect OnVisible doesn't seem to be working

I'll give that a try! I'll come back with the results! 🙂

Highlighted
Community Support
Community Support

Re: ClearCollect OnVisible doesn't seem to be working

Hi @Anonymous ,

Which screen's OnVisible property is set to the ClearCollect formula you mentioned above?

 

The OnVisible property of current screen would be fired only when you navigate to the current screen from another screen. Please make sure you have set the OnVisible property of the screen (where you need to use the actual_supplierID collection) to the ClearCollect formula you used.

 

Based on the issue that you mentioned, I have made a test on my side, the OnVisible property of the screen fires well. Please also consider modify your formula as below:

Clear(actual_supplierID);
ForAll( Filter( '[dbo].[OldSuppliers]', SourcingRecordId = Record.Id ).Identifier, Colelct(actual_supplierID, LookUp('[cube_GroupSourcing].[Supplier]', Supplier_x0020_Code = Identifier)) )

In addition, you could also consider set the OnHidden property of the screen where you set the Record variable to following formula (instead of OnVisible property of target screen):

ClearCollect(
    actual_supplierID,
    ForAll(
        Filter(
            '[dbo].[OldSuppliers]',
            SourcingRecordId = Record.Id
        ).Identifier,
        LookUp(
            '[cube_GroupSourcing].[Supplier]',
            Supplier_x0020_Code = Identifier
        )
    )
);

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Anonymous
Not applicable

Re: ClearCollect OnVisible doesn't seem to be working

As both of you suggest, moving the logic away from OnVisible seems to help.

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,404)