I’m working on a Power Apps application where I have a screen called visualizacaoSolicitacao that allows users to view and update tickets in a SharePoint list. The app includes a chat-like feature where users can add comments to a column called [Comentários] in the list [Automação – Notas de Débito].
The functionality I’m trying to achieve is to append new messages to the existing ones in the [Comentários] column. Each entry should include the date, time, and user name, followed by the message text, and all entries should be preserved without overwriting the previous ones.
Here’s the code of the Button2 I’m currently using:
// Store the current value of 'Comentários' in a context variable
UpdateContext({ currentDetails: gblSelectedItem.Comentários });;
// Debugging: Check the current value in the context
Notify("Current details: " & currentDetails);;
// Patch with concatenation
Patch(
'Automação - Notas de Débito';
gblSelectedItem;
{
Comentários:
Coalesce(
currentDetails; "" // Corrects the argument separation
) &
"<br><br>" & // Adds two line breaks
"<b>" & Text(Now(); "[$-pt-BR]dd-mm-yyyy hh:mm:ss") & " - " & User().FullName & ":</b>" &
"<br>" &
Input_Text.Text
}
);;
// Reset the input field
Reset(Input_Text);;
// Notify the user that the details were updated
Notify("Details updated", NotificationType.Information);;
When I add a new message, instead of appending the new entry with a line break, the app is updating the last message, replacing it with the new one. I need the new message to be added as a new entry below the previous ones, not overwrite them.
What I’ve tried:
Ensuring currentDetails is correctly retrieved.
Using the Concatenate function instead of simple string concatenation.
Verifying that gblSelectedItem is correctly set to the current item.
Despite these efforts, the issue persists, and the last message always gets overwritten instead of the new message being appended.
Question:
How can I modify my code to correctly append new messages to the [Comentários] column while preserving the previous ones?
Thank you in advance for your help!
Message 1
Message 2 with the refreshed