// Validate inputs If( IsBlank(cmbCondition.Selected), Notify("Please select a Condition", NotificationType.Error), IsEmpty(cmbRack.SelectedItems), Notify("Please select at least one Rack", NotificationType.Error), IsBlank(txtDaysShift.Value) || Value(txtDaysShift.Value) <= 0, Notify("Please enter a valid number of days", NotificationType.Error), // If validation passes, collect affected records BEFORE update ClearCollect( colAffectedRecords, AddColumns( Filter( SEL, cmbCondition.Selected.Value in Condition.Value && !IsBlank(LookUp(cmbRack.SelectedItems, Value = Rack)) ), OldEWD_Backup, EWD, NewEWD_Calc, DateAdd(EWD, Value(txtDaysShift.Value), TimeUnit.Days), ConditionText, cmbCondition.Selected.Value ) ); // Update records ForAll( colAffectedRecords, Patch( SEL, LookUp(SEL, ID = ID), {EWD: NewEWD_Calc} ) ); // Send email notification Office365Outlook.SendEmailV2( User().Email, "EWD Update Notification - " & CountRows(colAffectedRecords) & " Records Modified", "
Updated By: " & User().FullName & " (" & User().Email & ")
Date & Time: " & Text(Now(), "dd/mmm/yyyy hh:mm AM/PM") & "
Records Affected: " & CountRows(colAffectedRecords) & "
Days Shifted: " & txtDaysShift.Value & " day(s)
| ID | Title | Incubation Date | Mfg Date | Exp Date | Condition | EWD (Before) | EWD (After) |
|---|---|---|---|---|---|---|---|
| " & Text(ID) & " | " & Title & " | " & Text(IncDate, "dd/mmm/yyyy") & " | " & Text(MfgDate, "dd/mmm/yyyy") & " | " & Text(ExpDate, "dd/mmm/yyyy") & " | " & ConditionText & " | " & Text(OldEWD_Backup, "dd/mmm/yyyy") & " | " & Text(NewEWD_Calc, "dd/mmm/yyyy") & " |
This is an automated notification from the Stability Studies Management System.
", { Cc: "email1@company.com; email2@company.com", Importance: "Normal" } ); Notify( "Successfully updated " & CountRows(colAffectedRecords) & " records and sent notification email!", NotificationType.Success ); // Reset the form Reset(cmbCondition); Reset(cmbRack); Reset(txtDaysShift) )