web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Global or context vari...
Power Apps
Answered

Global or context variable unchanged if page not refreshed

(0) ShareShare
ReportReport
Posted on by 1,594

On a SharePoint list where I customized the form using Powerapps:

  1. I select item ID 1 and click MODIFY
  2. The Powerapps form starts and sets a global (or context) variable A to FALSE in the OnStart or OnVisible event of the screen
  3. In the form I click on a button which sets A to TRUE
  4. I close the form by clicking on CANCEL
  5. I select item ID 2 and click MODIFY
  6. My variable A is still TRUE -> OnStart and OnVisible events do not re-trigger if the web is not refreshed

 

Anyone knows a way around this ? I would like to do things every time a form is displayed even if I don't refresh the page but just go from one list item to another...

Categories:
I have the same question (0)
  • Verified answer
    Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    I believe this is a bug and I can reproduce it in my environment. I think I have a work around. I tried this in my environment and it seem to work. Move your variable to the OnVisible property of the screen then add "Navigate(FormScreen1, ScreenTransition.None)" to the OnNew, OnEdit and OnView properties of the SharePointIntegration control.

     

    OnView Example: ViewForm(SharePointForm1); Navigate(FormScreen1, ScreenTransition.None)

     

    By adding the Navigate() it appears to trigger the OnVisible property which will then reset your variable.

     

    @dinusc, @v-monli-msft, @v-xida-msft or @v-micsh-msft,

    Can you verify that this is a bug and if so, send it to the product team?

  • v-xida-msft Profile Picture
    on at

    Hi @R3dKap,

     

    Could you please share a bit more about your scenario?

     

    I have made a test and the issue is confirmed on my side. 

     

    There are some things to keep in your mind when you customize forms:



    "The properties for the SharePointIntegration control may not be available in OnStart or OnVisible, and those events execute only once while the list is loaded. You can use OnNewOnView, or OnEdit formulas to run logic before the form is shown to the user every time"

     


     

    More details about the things that you need to keep in mind when customizing forms, please check the following article:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/sharepoint-form-integration#customize-the-default-form

     

    In other words, the OnStart or OnVisible property could only be fired once when you edited your list (Just when you edit your list firstly), when you clicked the "Cancel" button, it just hide the custom list form rather than close the custom list form.

     

    As an alternative solution, you could consider take a try to initialize/set a global variable within the OnEdit property of the SharePointIntegration control:

     

    Set OnEdit property of the SharePointIntegration control to following formula:

    EditForm(SharePointForm1);Set(VariableA,false)

    1.JPG

     

    Set the OnSelect property of the Button control to following formula:

    Set(VariableA,true)

     

    Best regards,

    Kris

  • R3dKap Profile Picture
    1,594 on at

    Oh boy ! You maide my day ! Thank you so much... It works fine !

  • seangorm Profile Picture
    33 on at

    Jeff, I can't describe the difference your advice has made. Thanks so much. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard