powerappspower-platform

PowerApp - Data isn't loading in the initial OnSelect


I have a PowerApp application that looks like this

PowerApp Overview

the "Learn about" section is supposed to be populated with links from "colActiveRelatedLinks" collection and when I look at the "Items" property of the component I see that it is returning the data that I expect data returned

But, the links fail to load in.

However, the links load correctly if I click on a new task in the left menu (for example// process new payment request) and then click back on the same "Process third party" task.

loaded in properly

So it appears there seems to be an issue with the initial "OnSelect" items in the task list as it selects the first one by default.

So how can I fix my app to have it load as expected the first time?

I tried clearing the collection before the ClearCollect like this

Clear(colActiveRelatedLinks);
ClearCollect(colActiveRelatedLinks, ForAll(Split(gblActiveTask.'Related Link Item', Char(10)) As i, LookUp('Related Links', 'Unique ID' = i.Value)));

But that didn't work for me


Solution

  • Ok, so on your left menu, you have code to change a variable, or populate a collection etc... (please correct me if I am wrong here).

    You are correct in saying the initial loading of the gallery highlights the first item (or default item), but does not execute OnSelect.

    The answer then, is to place some code in the page OnVisible to do what your OnSelect does.

    For Example:

    ClearCollect(
      colActiveRelatedLinks,
        ForAll(
          Split(First(colTasks).'Related Link Item', Char(10)) As i,
          LookUp('Related Links', 'Unique ID' = i.Value)
        )
    );