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 / Prevent Patch command ...
Power Apps
Unanswered

Prevent Patch command from refreshing Gallery's

(0) ShareShare
ReportReport
Posted on by

I have a PowerApp running that has some complicated dropdowns that are working great thanks to help from @RandyHayes  

The issue I'm running into now is that when we update an item in the 2nd gallery( taskgallery), it updates the item, then refreshes the app.

Example:

Selected Function = "Employee Experience" - Selected Process = "Change Enablement" … Add to Comments field:

beforesave.png

After clicking the Save Icon, the App returns to the default gallery view:
aftersave.png

At times the users need to update multiple Tasks that are listed.
The first dropdown(Dropdown_Function) formula is: 
Sort(GroupBy( GroupBy( GroupBy( AddColumns(ndworkplan, "txtFunction", Function.Value), "txtFunction", "Subprocess","Milestone_x0020_ID", "Process", "Milestone_x0020_Name", "Task_x0020_ID"),"txtFunction","Process", "Milestones"), "txtFunction", "Processes" ),txtFunction,Ascending)

The 2nd dropdown( Dropdown_Process) formula is: Sort(Dropdown_Function.Selected.Processes,Process,Ascending) 

The First Gallery (MilestoneGallery) has items = Dropdown_Process.Selected.Milestones

The 2nd gallery (TaskGallery) has Items = MilestoneGallery.Selected.Task_x0020_ID

 and OnSelect =  Set(CurrentSelectedITem, ThisItem)

The "Save" Icon has  OnSelect = Patch(ndworkplan,CurrentSelectedITem, {Comments: CommentGal.Text}))
and it updates the comments field as expected, but also refreshes the entire view...

So the user is forced to go back through the steps to find the milestone and tasks they want to update.

Is there a way to prevent the App from refreshing after saving one task item?

Categories:
I have the same question (0)
  • v-yutliu-msft Profile Picture
    on at

    Hi @Anonymous ,

    Do you mean that if you update a new record, gallery1 and gallery2's item sorting will change?

    I suggest you sort them according to the submitted time.

    Then, if you submit a new item, the latest record will be the first too.

    Set the gallery1's Items: 

    SortByColumns(
    AddColumns(Dropdown_Process.Selected.Milestones,
    "lastmodified",
    First(SortByColumns(Milestone_x0020_ID,"Modified",Descending)).Modified),
    "lastmodified",Descending
    )

    Set the gallery2's Items:

    SortByColumns(MilestoneGallery.Selected.Task_x0020_ID,"Modified",Descending)

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    Maybe this will help clear up the issue..

    Users go to the app and select a Function and process from the drop downs.
    Then user select a Milestone from the 1st Gallery (MilestoneGallery), which displays all tasks associated to that Milestone in the 2nd gallery(TaskGallery).

    beforesave.png

    They can then update those tasks directly in that gallery.

    But, as soon as they click the Save Button, the entire application "Resets" back to the defualt view.

    The Changes are saved, but now the end user needs to go back through all those steps to update other tasks for that Milestone.

    Some of these Milestones have 10+ task associated with them, so I'd like to make it so they can save one task, then scroll down, update a 2nd task, save, etc. until they are done updating all the tasks for that Milestone.

     

  • Community Power Platform Member Profile Picture
    on at

    Hey,

     

    just a wee question, do your dropdowns have Reset feild false?

  • Community Power Platform Member Profile Picture
    on at

    Yes, both Dropdowns have Reset = False

  • Community Power Platform Member Profile Picture
    on at

    Just thought I'd check in to see if any one has any thoughts?

  • Community Power Platform Member Profile Picture
    on at

    Hi @RandyHayes are you able to provide any insight on this? 

     

    Thanks, 

     

    @Anonymous 

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Anonymous 

    Are you still having trouble with this?

    Your problem is that you are updating the collection ndworkplan in your Save formula.  Since your first dropdown is based on that collection, it will tend to reevaluate the list and then all the associate items will change because, you have not mentioned any of your default properties, and I am guessing those are not set.

     

    So...you can do one for at least two things.  

    1) change your first dropdown to be based on a collection instead.  A collection is a snapshot in time, so it will not change unless you change it.

    Consider putting a formula such as this in your OnVisible action of your screen (BTW - not even addressing that I believe your GroupBy logic might be a bit backward, but let's go with it at this point):

    ClearCollect(colFunctions,
     Sort( 
    GroupBy(
    GroupBy(
    GroupBy(
    AddColumns(ndworkplan, "txtFunction", Function.Value),
    "txtFunction",
    "Subprocess",
    "Milestone_x0020_ID",
    "Process",
    "Milestone_x0020_Name",
    "Task_x0020_ID"),
    "txtFunction",
    "Process",
    "Milestones"),
    "txtFunction",
    "Processes" ),
    txtFunction,
    Ascending
    ) )

    Then set the Items property of your first dropdown to colFunctions

     

    2) Set defaults - set a variable on each of the OnChange/OnSelect actions of the dropdowns and the galleries that capture the current value and then assign that variable in the default property of the control.

    Ex. if Function is a dropdown control (not a combobox), then in the OnChange action : UpdateContext({lclCurrentFunction : yourDropDown.Selected.Value})  Then in the Default property of the Function DropDown, put in this formula : lclCurrentFunction

    Repeat this on the other controls with their own variables and then they will at least retain their selected item if the underlying collection is patched.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    on at

    Thanks, I'll take a look today to see if this works.

  • Community Power Platform Member Profile Picture
    on at

    @RandyHayes  I've tried your first idea but now when I try to save I get "Unknown error" and no explanation when running or testing what the "Unknown error" is.

    The Formula for the Save button is:

    Patch(ndworkplan,CurrentSelectedITem, {Comments: CommentGal.Text}, {'Task Name': TaskNameGal.Text}, {'Start Date': StartDateGal.SelectedDate}, {'Due Date': DueDateGal.SelectedDate}, {'Percent Complete': PercentGal}, {Owner: OwnerGal.Text})

     

    Where "Gal" is the field name for the current Gallery.

    I'll see if I can walk through your 2nd idea tomorrow.

  • Community Power Platform Member Profile Picture
    on at

    @RandyHayes  Never mind on my last post.. "Percent Complete" was casuing an issue due to invild type( even though the formula never errored out until I tested it)..

     

    Going to go back and re-add your first idea.

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 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard