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

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
Dual Super User
Dual Super User

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

Community Support Team
Community Support Team

Re: ClearCollect OnVisible doesn't seem to be working

Hi @kevinruder ,

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
Dual Super User
Dual Super User

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.
kevinruder
Level: Powered On

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.

Dual Super User
Dual Super User

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

kevinruder
Level: Powered On

Re: ClearCollect OnVisible doesn't seem to be working

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

Community Support Team
Community Support Team

Re: ClearCollect OnVisible doesn't seem to be working

Hi @kevinruder ,

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

kevinruder
Level: Powered On

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
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 326 members 5,937 guests
Recent signins:
Please welcome our newest community members: