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 / Patch function randoml...
Power Apps
Answered

Patch function randomly stops working or patches sections of string (Issue with 3.24073.20?)

(1) ShareShare
ReportReport
Posted on by 2,563
Hi,
 
I have had this patch function working for a very longtime, I recently update other sections of the app and notice that the patch was behaving wierd randomly.
I also notice that Text boxes randomly showed a border, this was not something I changed the app changed it when going from one version to another, this was easy to resolve setting the border back to 0 again.
 
But for my Patch function I know have the following issues happening randomly.
  
Example 1: Press Patch, nothing gets patch no error message, jumps out of the item screen back to gallery, like it should after is patched successfully, the text i entered is not patched and it is still available in the text box so I can just click save again and it will patch it it.
  
Example 2: I write in the textbox: "Hello World, how are you doing today" hit save button, it only patches Hello World and leaves out the rest of the text. randomly selected text will get patched.
  
Example 3: You have to click save button twice, this happens alot (Modern button controls)
 
Example 4: Everything works as it should.
 
The issue presented with my patch have also been viewed when i do submitform, it will not submit entire text field selecting some text only and leaves out some.
 
This all started happening when i went from version: 3.24045.24 to 3.24073.20
 
Here is my patch code for the button:
If(
    TabListMenu.Selected.Value = "Message" && !IsBlank(TextInputTicket.Value),
    Patch(
        Helpdesk,
        CurrentItem, // Use the context variable set in the Gallery
        {
            'Case Comments': "<b>" & Char(10) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(
                Now(),
                "[$-en-US]yyyy/mm/dd hh:mm"
            ) & "</span> <br> " & TextInputTicket.Value & CurrentItem.'Case Comments',
            LastComment: TextInputTicket.Value,
            'Last Modified By': {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Department: "",
                DisplayName: User().FullName,
                Claims: "i:0#.f|membership|" & Lower(User().Email),
                Email: User().Email,
                JobTitle: "",
                Picture: ""
            },
            'Last Comment Made By': {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Department: "",
                DisplayName: User().FullName,
                Claims: "i:0#.f|membership|" & Lower(User().Email),
                Email: User().Email,
                JobTitle: "",
                Picture: ""
            }
        }
    );
    If(
        !IsEmpty(Errors(Helpdesk)),
        // Errors occurred, handle them and do not reset TextInputTicket
        Notify(
            First(Errors(Helpdesk)).Message,
            NotificationType.Error
        ),
        // No errors, proceed with additional actions
        UpdateContext(
            {
                CurrentItem: LookUp(
                    Helpdesk,
                    ID = CurrentItem.ID
                )
            }
        );
        Reset(TextInputTicket)
    )
);

If(
    TabListMenu.Selected.Value = "Worklog" && !IsBlank(TextInputTicket.Value),
    Patch(
        Helpdesk,
        CurrentItem, // Use the context variable set in the Gallery
        {
            Worklog: "<b>" & Char(13) & Char(13) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(
                Now(),
                "[$-en-US]yyyy/mm/dd hh:mm"
            ) & "</span> <br> " & Char(13) & TextInputTicket.Value & CurrentItem.Worklog,
            'Last Modified By': {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Department: "",
                DisplayName: User().FullName,
                Claims: "i:0#.f|membership|" & Lower(User().Email),
                Email: User().Email,
                JobTitle: "",
                Picture: ""
            }
        }
    );
    If(
        !IsEmpty(Errors(Helpdesk)),
        // Errors occurred, handle them and do not reset TextInputTicket
        Notify(
            First(Errors(Helpdesk)).Message,
            NotificationType.Error
        ),
        // No errors, proceed with additional actions
        UpdateContext(
            {
                CurrentItem: LookUp(
                    Helpdesk,
                    ID = CurrentItem.ID
                )
            }
        );
        Reset(TextInputTicket)
    )
);

If(
    TabListMenu.Selected.Value = "Close" && !IsBlank(TextInputTicket.Value),
    Patch(
        Helpdesk,
        CurrentItem, // Use the context variable set in the Gallery
        {
            Resolution: "<b>" & Char(13) & Char(13) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(
                Now(),
                "[$-en-US]yyyy/mm/dd hh:mm"
            ) & "</span> <br> " & Char(13) & TextInputTicket.Value & CurrentItem.Resolution,
            'Last Modified By': {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Department: "",
                DisplayName: User().FullName,
                Claims: "i:0#.f|membership|" & Lower(User().Email),
                Email: User().Email,
                JobTitle: "",
                Picture: ""
            },
            Status: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                Id: 4,
                Value: "Closed"
            }
        },
        {
            'Assigned To': {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims: "i:0#.f|membership|" & Lower(User().Email),
                Department: "",
                DisplayName: User().FullName,
                Email: User().Email,
                JobTitle: "",
                Picture: ""
            }
        }
    );
    If(
        !IsEmpty(Errors(Helpdesk)),
        // Errors occurred, handle them and do not reset TextInputTicket
        Notify(
            First(Errors(Helpdesk)).Message,
            NotificationType.Error
        ),
        // No errors, proceed with additional actions
        UpdateContext(
            {
                CurrentItem: LookUp(
                    Helpdesk,
                    ID = CurrentItem.ID
                )
            }
        );
        Reset(TextInputTicket)
    )
);

If(
    TabListMenu.Selected.Value = "Close",
    // Additional logic for filtering TicketsCollection based on TabList1.Selected.Value
    If(
        TabList1.Selected.Value = "Unassigned",
        ClearCollect(
            TicketsCollection,
            Filter(
                Helpdesk,
                Status.Value = "Unassigned"
            )
        );
        UpdateContext({itemSelected: false})
    );
    If(
        TabList1.Selected.Value = "My Tickets",
        ClearCollect(
            TicketsCollection,
            Filter(
                Helpdesk,
                ('Assigned To'.DisplayName = User().FullName) && ((Status.Value = "Assigned") || (Status.Value = "In Progress") || (Status.Value = "Waiting for user response") || (Status.Value = "Waiting for external resource") || (Status.Value = "Backlog"))
            )
        );
        UpdateContext({itemSelected: false})
    );
    If(
        TabList1.Selected.Value = "Closed",
        ClearCollect(
            TicketsCollection,
            Filter(
                Sort(
                    Helpdesk,
                    ID,
                    SortOrder.Descending
                ),
                'Assigned To'.DisplayName = User().FullName && Status.Value = "Closed"
            )
        );
        UpdateContext({itemSelected: false});
        Notify(
            "Ticket was closed and placed under Closed tickets.",
            NotificationType.Success,
            600
        )
    );
    If(
        TabList1.Selected.Value = "All",
        ClearCollect(
            TicketsCollection,
            SortByColumns(
                Helpdesk,
                "CreatedDate",
                SortOrder.Descending
            )
        );
        UpdateContext({itemSelected: false})
    )
)
 
Categories:
I have the same question (0)
  • JimmyW Profile Picture
    2,563 on at
    I can add that I can replicate the issue, it seems as the text input box is hanging on to being selected, so the first time you press save, nothing happens if you are to fast, second time it works.
     
    Changes made to the code for better overview etc, still same issue.
     
    // Define user details and timestamp once
    Set(
        currentUser,
        {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            Department: "",
            DisplayName: User().FullName,
            Claims: "i:0#.f|membership|" & Lower(User().Email),
            Email: User().Email,
            JobTitle: "",
            Picture: ""
        }
    );
    
    Set(
        timestamp,
        "<b>" & Char(10) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(Now(), "[$-en-US]yyyy/mm/dd hh:mm") & "</span> <br> "
    );
    
    // Handle Patch Operations
    If(
        !IsBlank(TextInputTicket.Value),
        Switch(
            TabListMenu.Selected.Value,
            "Message",
            Patch(
                Helpdesk,
                CurrentItem,
                {
                    'Case Comments': timestamp & TextInputTicket.Value & CurrentItem.'Case Comments',
                    LastComment: TextInputTicket.Value,
                    'Last Modified By': currentUser,
                    'Last Comment Made By': currentUser
                }
            ),
            "Worklog",
            Patch(
                Helpdesk,
                CurrentItem,
                {
                    Worklog: timestamp & TextInputTicket.Value & CurrentItem.Worklog,
                    'Last Modified By': currentUser
                }
            ),
            "Close",
            Patch(
                Helpdesk,
                CurrentItem,
                {
                    Resolution: timestamp & TextInputTicket.Value & CurrentItem.Resolution,
                    'Last Modified By': currentUser,
                    Status: {
                        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                        Id: 4,
                        Value: "Closed"
                    },
                    'Assigned To': currentUser
                }
            )
        );
    
        // Handle Errors and Reset
        If(
            !IsEmpty(Errors(Helpdesk)),
            Notify(First(Errors(Helpdesk)).Message, NotificationType.Error),
            UpdateContext({ CurrentItem: LookUp(Helpdesk, ID = CurrentItem.ID) });
            Reset(TextInputTicket)
        )
    );
    
    // Handle Ticket Filtering based on Tab Selection
    If(
        TabListMenu.Selected.Value = "Close",
        Switch(
            TabList1.Selected.Value,
            "Unassigned",
            ClearCollect(TicketsCollection, Filter(Helpdesk, Status.Value = "Unassigned")),
            "My Tickets",
            ClearCollect(
                TicketsCollection,
                Filter(
                    Helpdesk,
                    ('Assigned To'.DisplayName = User().FullName) && (Status.Value in ["Assigned", "In Progress", "Waiting for user response", "Waiting for external resource", "Backlog"])
                )
            ),
            "Closed",
            ClearCollect(
                TicketsCollection,
                Filter(
                    Sort(Helpdesk, ID, SortOrder.Descending),
                    'Assigned To'.DisplayName = User().FullName && Status.Value = "Closed"
                )
            );
            Notify("Ticket was closed and placed under Closed tickets.", NotificationType.Success, 600),
            "All",
            ClearCollect(TicketsCollection, SortByColumns(Helpdesk, "CreatedDate", SortOrder.Descending))
        );
        UpdateContext({ itemSelected: false })
    )
    
     
  • JimmyW Profile Picture
    2,563 on at
    Think i found the issue, maybe some more people will have this, my default value is however Focus Out I cannot to Focus in.
  • Verified answer
    JimmyW Profile Picture
    2,563 on at
    Resolved selecting to KeyPress, only works after publishing the app, if you stay in the testing it will not work as inteended but after publishing it works correctly again.

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard