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

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Gallery field not holding last user input when scrolling away from focus screen area

(0) ShareShare
ReportReport
Posted on by 7
Gallery has a Slider for scoring and associated Comments field for 13 survey questions however the Comments field for each of the 13 survey questions is not holding the last comment when the user scrolls away from the focus screen area. Previous Comments are held. Just not the last one.
 
 
FieldTeamSurvey.OnVisible:
// Build question collection with numeric Score column
If(
    IsEmpty(colResponses),
    ClearCollect(
        colResponses,
        ForAll(
            Filter('C&OAnalysisQuestionDim', Role = "Field Team"),
            {
                QuestionNum: ThisRecord.QuestionNum,
                QuestionID: ThisRecord.Title,           // Title from QuestionsDim = QFTxx
                Question: ThisRecord.Question,
                Score: 0,                                // numeric default
                Comments: ""                            // Stored committed comments
            }
        )
    )
)

FieldTeamSurvey GalleryFT Items:
colResponses

FieldTeamSurvey GalleryFT txtComment Default:
ThisItem.Comments

FieldTeamSurvey GalleryFT txtComment DelayOutput:
true

FieldTeamSurvey GalleryFT txtComment OnChange:
Patch(colResponses, ThisItem, { Comments: Self.Text })

FieldTeamSurvey GalleryFT sldScore Default:
ThisItem.Score

FieldTeamSurvey GalleryFT sldScore OnChange:
Patch(colResponses, ThisItem, { Score: sldScore.Value })

FieldTeamSurvey.IconAccept1_1.OnSelect:
If(
    CountIf(colResponses, Score = 0) > 0,
    Notify("Please complete all survey questions before submitting.", NotificationType.Error),
        // Commit any on-screen text into colResponses
ForAll(
    GalleryFT.AllItems,
    UpdateIf(
        colResponses,
        QuestionNum = ThisRecord.QuestionNum,
        {
            Comments: txtComment.Text,
            Score: Value(sldScore.Value)
        }
    )
);
    // Create the full SharePoint record and capture it
    Set(
        varSavedRecord,
        Patch(
            'C&O Analysis Survey Field Team',
            Defaults('C&O Analysis Survey Field Team'),
            {
                ResponseID: GUID(),
                ResponseGroupID: varResponseGroupID,
                Role: { Value: "Field Team" },
                // Metadata
                Survey_x0020_Date: varFieldMeta.Survey_x0020_Date,
                Reviewer: varFieldMeta.Reviewer,
                Respondent: varFieldMeta.Respondent,
                Region: varFieldMeta.Region,
                Location: varFieldMeta.Location,
                Regional_x0020_Manager: varFieldMeta.Regional_x0020_Manager,
                Department: varFieldMeta.Department,
                Department_x0020_Number: varFieldMeta.Department_x0020_Number,
                Project: varFieldMeta.Project,
                Project_x0020_Number: varFieldMeta.Project_x0020_Number,
                Leader_x0020_Name: varFieldMeta.Leader_x0020_Name,
                Leader_x0020_Position: varFieldMeta.Leader_x0020_Position,
                Frontline_x0020_Leader_x0020_Nam: varFieldMeta.Frontline_x0020_Leader_x0020_Nam,
                Frontline_x0020_Leader_x0020_Pos: varFieldMeta.Frontline_x0020_Leader_x0020_Pos,
                Field_x0020_Person: varFieldMeta.Field_x0020_Person,
                // Answers
                Q01: { Value: Text(LookUp(colResponses, QuestionNum="Q01", Score)) },
                'Q01 Comments': LookUp(colResponses, QuestionNum="Q01", Comments),
                Q02: { Value: Text(LookUp(colResponses, QuestionNum="Q02", Score)) },
                'Q02 Comments': LookUp(colResponses, QuestionNum="Q02", Comments),
                Q03: { Value: Text(LookUp(colResponses, QuestionNum="Q03", Score)) },
                'Q03 Comments': LookUp(colResponses, QuestionNum="Q03", Comments),
                Q04: { Value: Text(LookUp(colResponses, QuestionNum="Q04", Score)) },
                'Q04 Comments': LookUp(colResponses, QuestionNum="Q04", Comments),
                Q05: { Value: Text(LookUp(colResponses, QuestionNum="Q05", Score)) },
                'Q05 Comments': LookUp(colResponses, QuestionNum="Q05", Comments),
                Q06: { Value: Text(LookUp(colResponses, QuestionNum="Q06", Score)) },
                'Q06 Comments': LookUp(colResponses, QuestionNum="Q06", Comments),
                Q07: { Value: Text(LookUp(colResponses, QuestionNum="Q07", Score)) },
                'Q07 Comments': LookUp(colResponses, QuestionNum="Q07", Comments),
                Q08: { Value: Text(LookUp(colResponses, QuestionNum="Q08", Score)) },
                'Q08 Comments': LookUp(colResponses, QuestionNum="Q08", Comments),
                Q09: { Value: Text(LookUp(colResponses, QuestionNum="Q09", Score)) },
                'Q09 Comments': LookUp(colResponses, QuestionNum="Q09", Comments),
                Q10: { Value: Text(LookUp(colResponses, QuestionNum="Q10", Score)) },
                'Q10 Comments': LookUp(colResponses, QuestionNum="Q10", Comments),
                Q11: { Value: Text(LookUp(colResponses, QuestionNum="Q11", Score)) },
                'Q11 Comments': LookUp(colResponses, QuestionNum="Q11", Comments),
                Q12: { Value: Text(LookUp(colResponses, QuestionNum="Q12", Score)) },
                'Q12 Comments': LookUp(colResponses, QuestionNum="Q12", Comments),
                Q13: { Value: Text(LookUp(colResponses, QuestionNum="Q13", Score)) },
                'Q13 Comments': LookUp(colResponses, QuestionNum="Q13", Comments),
                Follow_x002d_up_x0020_Action: varFollowUpAction,
                Comments: varGeneralComments
            }
        )  
    )
);
// Navigate to the attachments screen
Navigate(FieldTeamAttachmentScreen, ScreenTransition.Fade)
 
I have the same question (0)
  • WarrenBelz Profile Picture
    151,135 Most Valuable Professional on at
    Gallery field not holding last user input when scrolling away from focus screen area
    Firstly as you are doing this when the user changes a value in  GalleryFT txtComment 
    Patch(
       colResponses, 
       ThisItem, 
       {Comments: Self.Text}
    )
    
    If the Items of the Gallery is colResponses, it should hold the value - is this the case ?
     
    Also cutting through all of that code, you appear to be doing the following:-
    • You have a Gallery called GalleryFT with the Items property of colResponses (as mentioned above)
    • On the OnChange property of a number of controls in the Gallery, you are updating colResponses with input from the user
    • You then have an icon IconAccept1_1 outside the gallery which when selected firstly checks that all the Score fields in the gallery contain a value other than zero, then update colResponses with the values for the gallery.
      This point brings my first question - you have already done this OnChange of the two controls in the point above - why do it again ?
    • You are then patching a record to 'C&O Analysis Survey Field Team',
      Another question here - it is outside the ForAll statement above, so will only patch the first record in the collection.
    Can you also please confirm if all of the above is correct.
  • PM-14102335-0 Profile Picture
    7 on at
    Gallery field not holding last user input when scrolling away from focus screen area
    Hi Warren, thanks for the response.

    Yes, since GalleryFT.Items = colResponses, the Patch() on txtComment.OnChange should update the Comments field correctly — but only if the user defocuses the input before scrolling. If not, OnChange may not fire, especially with DelayOutput = true.

    You're right that IconAccept1_1.OnSelect repeats the update logic. However, this acts as a safeguard to ensure all visible values — especially the last comment — are committed before submission.

    Regarding the SharePoint Patch(), it’s outside the ForAll() because I am submitting a single consolidated record, not individual items. Each question’s score and comment is retrieved via LookUp() from colResponses, so this is intentional.

    The problem likely stems from PowerApps not firing the OnChange event if the user types a comment and scrolls away without defocusing the text input (i.e., without triggering a change event) but have not found a way around this behaviour.
  • Verified answer
    WarrenBelz Profile Picture
    151,135 Most Valuable Professional on at
    Gallery field not holding last user input when scrolling away from focus screen area
    I see your issue now when you refer to "focus" - unfortunately the OnChange event triggers when the user leaves the control for a good reason - Power Apps has no idea when the user wants to finish typing - it would not be helpful if the user paused while checking something and then had the event trigger. It does however also trigger when the user presses the Enter key, so this may come down to a bit of training.
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful?
    Visit my blog
    Practical Power Apps    LinkedIn  
  • PM-14102335-0 Profile Picture
    7 on at
    Gallery field not holding last user input when scrolling away from focus screen area
    Thanks Warren.
     
    After all my attempts, I have come to the same conclusion.
     
    Thanks for the validation, I can now stop trying to find a way around this!....
  • WarrenBelz Profile Picture
    151,135 Most Valuable Professional on at
    Gallery field not holding last user input when scrolling away from focus screen area
    You might mark my last response as the solution to make it easier to find for other people with the same question.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 829 Most Valuable Professional

#2
developerAJ Profile Picture

developerAJ 489

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 395 Super User 2025 Season 2

Last 30 days Overall leaderboard