Damien MEYER
Damien MEYER

Reputation: 85

Loading troubles in powerapps

I had some troubles on form loading. Here, I will show 2 examples, 1 label and 1 button.

Label.Text code :

If(
DataCardValue13.Text = Concatenate(
    'Utilisateursd''Office365_1'.MyProfile().Surname;
    " ";
    'Utilisateursd''Office365_1'.MyProfile().GivenName
);
"true";
"false"
)

And Button.OnVisible code :

If(
ThisItem.Etat = "Validé" || ThisItem.Etat = "Refusé";
false;
If(
    DataCardValue13.Text = Concatenate(
        'Utilisateursd''Office365_1'.MyProfile().Surname;
        " ";
        'Utilisateursd''Office365_1'.MyProfile().GivenName
    );
    true;
    If(
        ThisItem.Author.DisplayName = Concatenate(
            'Utilisateursd''Office365_1'.MyProfile().Surname;
            " ";
            'Utilisateursd''Office365_1'.MyProfile().GivenName
        );
        true;
        If(
            etat = "Nouveau";
            true;
            false
        )
    )
)
)

My trouble : if I load my form ten times, I will sometimes have false, sometimes true to the Label.Text. And, it's the same for the button. Sometimes it's visible, sometimes not. And DataCardValue13.Text = Concatenate()...

Maybe I'm doing it wrong, and code should be somewhere else to be load before the screen is show ?

And, subsidiary question : I had to use

DataCardValue13.Text = Concatenate(
        'Utilisateursd''Office365_1'.MyProfile().Surname;
        " ";
        'Utilisateursd''Office365_1'.MyProfile().GivenName
    )

to test if my connected user is the same as DataCardValue13.Text. This DataCardValue13 come from

`LookUp('DI - Portefeuilles';Title = DataCardValue11.Selected.Title;Controleur_x0020_de_x0020_gestio.DisplayName)`

which is MEYER Damien and User().FullName is Damien MEYER.

Thanks a lot for answering :)

Upvotes: 1

Views: 251

Answers (1)

Meneghino
Meneghino

Reputation: 1021

There are performance issues with connections such as User() and Office365Users(), in that each time the function is used it makes a new call to the server. This can cause delays or missing information.

One solution is to cache the User() or Office365Users() values in a global variable that can be used throughout the app without needing to make further calls to the server.

Here is a reference

Upvotes: 2

Related Questions