Set(varNotificationMessage, "");
Set(varNotificationType, NotificationType.Information); // Default to Information
If(
frmAllianceBDAgreementGeneral.Valid And frmAllianceBDAgreementDetoils.Valid,
// Use IfError to catch potential errors during the Patch operation
IfError(
Patch(
Contracts,
LookUp(
Contracts,
ID = Value(varCreatedSpItemId)
),
frmAllianceBDAgreementGeneral.Updates,
frmAllianceBDAgreementDetoils.Updates
),
// On Error
Set(varNotificationMessage, "Error: Some data failed to update. Please check your inputs and try again. Details: " & FirstError.Message),
Set(varNotificationType, NotificationType.Error),
Patch(
ErrorLogList,
Defaults(ErrorLogList),
{
AppName: "Your Power App Name",
ErrorTime: Now(),
ErrorMessage: FirstError.Message,
Context: "Updating Contracts item ID: " & Text(varCreatedSpItemId)
}
)
),
// If the forms are not valid (this part is outside the IfError for Patch)
Set(varNotificationMessage, "Please ensure all required fields are filled out correctly."),
Set(varNotificationType, NotificationType.Warning)
);
// Display the notification after the operation
If(
IsBlank(varNotificationMessage), // If no error occurred and forms were valid
Set(varNotificationMessage, "Data successfully updated in SharePoint!"),
Set(varNotificationType, NotificationType.Success)
);
Notify(varNotificationMessage, varNotificationType, 5000); // Display for 5 seconds
/*Optional: Navigate to a success screen or reset forms after successful update
If(varNotificationType = NotificationType.Success,
ResetForm(frmAllianceBDAgreementGeneral);
ResetForm(frmAllianceBDAgreementDetoils);
Navigate(UrScreenWanted)
);
*/
WarrenBelz
791
Most Valuable Professional
MS.Ragavendar
410
Super User 2025 Season 2
mmbr1606
275
Super User 2025 Season 2