Policy Tracker Fix Guide
One page, every confirmed fix kept in it, oldest first. Each entry has the exact control/property, the replacement formula, and a test to confirm it worked. Superseded by nothing — this page keeps growing instead of being replaced fix-by-fix.
What This Page Is
This is the working fix log for the Policy Tracker canvas app (repo PhadeDev/policy-tracker). Reset to empty on 2026-08-13 — the previous entries (personal OneDrive link blocking, address-bar link save crash, generic-icon hint) had already been applied in Studio for weeks and were no longer needed as a reference.
Urgent - Newsletter Missing Item Diagnostic
NewsletterPack · temporary label · no data changes
Use this before changing the live formula again. The current NewsletterPack filter only includes records that match the target Thursday date, have final approval by XO/ACOS/DCOMD/D Commander, are not already published, and are not marked as requiring external consultation. Title and content do not affect inclusion. Stage 1 prints every SharePoint row matching the target Thursday date and shows exactly which gate is excluding it.
Stage 1 - Prove The SharePoint Rows Qualify
- Open NewsletterPack in Power Apps Studio.
- Add a temporary Label anywhere on the screen.
- Set the label's
Textproperty to the formula below. - Set
AutoHeighttotrue, make it wide, and set the text size small enough to read the lines. - Preview the screen. If the missing item is printed with
include=false, the same line tells you which field is different. If the missing item is not printed at all, it is not matching the target Thursday date window.
With(
{_target: DateAdd(Today(), Mod(5 - Weekday(Today()) + 7, 7), "Days")},
Concat(
AddColumns(
Filter(
'Policy Proof Tracker',
'Planned Publish Date' >= _target &&
'Planned Publish Date' < DateAdd(_target, 1, "Days")
),
DebugLine,
Title &
" | date=" & Text('Planned Publish Date', "dd mmm yyyy") &
" | approval=" & Coalesce('Approved For Release By'.Value, "<blank>") &
" | published=" & Text(Published) &
" | external=" & Text('External consultation required') &
" | include=" &
Text(
(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &&
Published = false &&
Coalesce('External consultation required', false) = false
)
),
DebugLine,
Char(10)
)
)
colNewsletterPack and the galleries.
Stage 2 - Check The Collection And Both Galleries
Keep the temporary label and replace its Text with this formula. This does not change data. It prints the row count for colNewsletterPack, the two gallery counts, and the titles currently inside the collection.
"colNewsletterPack rows = " & CountRows(colNewsletterPack) & Char(10) &
"galPlainPack_1 visible rows = " & CountRows(galPlainPack_1.AllItems) & Char(10) &
"galEmailPreview_1 visible rows = " & CountRows(galEmailPreview_1.AllItems) & Char(10) &
Char(10) &
Concat(
colNewsletterPack,
Text(ID) &
" | " & PackTitle &
" | audience=" & PackAudience &
" | final=" & Text(IsFinalApproved),
Char(10)
)
colNewsletterPack rows is still 1, the live NewsletterPack.OnVisible or btnRefresh_1.OnSelect formula is not building the same result as Stage 1. If colNewsletterPack rows is 3 but a gallery count is lower or the screen still shows one card, the bug is in gallery rendering/layout, not the SharePoint filter.
Stage 3 - Print The Current Pack Gates Per Record
If Stage 1 shows the three titles but Stage 2 shows colNewsletterPack rows = 1, use this label formula next. It prints the strict consultation check and the blank-safe consultation check for every record in the Thursday date window.
With(
{_target: DateAdd(Today(), Mod(5 - Weekday(Today()) + 7, 7), "Days")},
Concat(
AddColumns(
Filter(
'Policy Proof Tracker',
'Planned Publish Date' >= _target &&
'Planned Publish Date' < DateAdd(_target, 1, "Days")
),
DebugLine,
Text(ID) &
" | " & Title &
" | approval=" & Coalesce('Approved For Release By'.Value, "<blank>") &
" | finalApprovalOK=" &
Text(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &
" | publishedOK=" & Text(Published = false) &
" | consultationStrictOK=" & Text('External consultation required' = false) &
" | consultationBlankSafeOK=" & Text(Coalesce('External consultation required', false) = false) &
" | fixedPackRule=" &
Text(
(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &&
Published = false &&
Coalesce('External consultation required', false) = false
)
),
DebugLine,
Char(10)
)
)
consultationStrictOK=false but consultationBlankSafeOK=true, apply Fix 4. If consultationBlankSafeOK=false, the record is genuinely consultation-ticked and should stay out of the newsletter.
finalApprovalOK=true and publishedOK=true. Apply Fix 4 below if those rows are not actually consultation-ticked.
Fix 1 - Publish Buttons No Longer Gated On External Consultation Flag
Main · property edit · no risk to formula syntax, changes real publish behaviour
Reported 2026-08-13: on a day with three items due, only one showed a per-item Publish button and Publish All read (1) instead of (3). It looked like an approval-based bug, but it wasn't — BossPublishBtn.Visible and PublishAllBtn never checked approval status at all. The actual gate was 'External consultation required' = false, present in four places (button visibility, the count shown in the button text, and both Filter() calls used when actually patching records). Two of the three items had that flag ticked. Decision: drop that condition everywhere so Publish/Publish All always show for boss users on unpublished, due items, regardless of the consultation flag.
- Open Main.
- In the Tree view, find BossPublishBtn (the per-item "⚡ Publish" button).
- Select
Visiblein the Properties dropdown, select all, and replace with this formula.
!IsEmpty(Filter(colBossButtonUsers, Lower(Email) = Lower(User().Email))) && ThisItem.'Planned Publish Date' <= Today() && ThisItem.Published = false
- Find PublishAllBtn (the group-header "Publish All (n)" button).
- Select
OnSelectin the Properties dropdown, select all, and replace with this formula.
// PublishAllBtn.OnSelect
Set(varPublishGroupDate, ThisItem.PlannedDate);
Set(varPublishGroupCount, CountRows(Filter(ThisItem.GroupedItems, Published = false)));
Clear(colPublishFailures);
ForAll(
Filter(ThisItem.GroupedItems, Published = false) As PubItem,
IfError(
Patch(
'Policy Proof Tracker',
LookUp('Policy Proof Tracker', ID = PubItem.ID),
{
Published: true,
'Published Date': varPublishGroupDate
}
); true,
Collect(colPublishFailures, {ID: PubItem.ID}); true
)
);
Set(varPublishFailCount, CountRows(colPublishFailures));
Refresh('Policy Proof Tracker');
RefreshActiveCache();
If(
varPublishFailCount = 0,
Notify(
"Published all " & varPublishGroupCount & " items for " & Text(varPublishGroupDate, "d mmm yyyy"),
NotificationType.Success
),
Notify(
varPublishFailCount & " of " & varPublishGroupCount & " items failed to publish for " & Text(varPublishGroupDate, "d mmm yyyy") & ". Please retry.",
NotificationType.Error
)
)
- Still on PublishAllBtn, select
Textand replace with this formula.
"Publish All (" & CountRows(Filter(ThisItem.GroupedItems, Published = false)) & ")"
- Still on PublishAllBtn, select
Visibleand replace with this formula.
!IsEmpty(Filter(colBossButtonUsers, Lower(Email) = Lower(User().Email))) && ThisItem.PlannedDate <= Today() && CountRows(Filter(ThisItem.GroupedItems, Published = false)) > 0
Fix 2 - Newsletter Pack Required Real Final Approval, Not Just Pillar Lead
NewsletterPack · property edit · changes which items appear in the pack
Reported 2026-08-13 alongside Fix 1: an item approved only by the Pillar Lead (not yet by ACOS or above) was still appearing in the newsletter pack. The Filter() that builds colNewsletterPack included 'Approved by Pillar Lead (Ready to Release)' = true as one of several OR'd conditions, so Pillar Lead approval alone was enough to qualify — even though a separate IsFinalApproved column (used only for the amber "pending" styling on the card) already correctly checked just the four senior sign-off values. Fix: removed the Pillar Lead OR branch from the qualifying filter, so an item only enters the pack once 'Approved For Release By' is XO, ACOS, DCOMD, or "D Commander" — DCOMD / D Commander is the Deputy Commander Cadets rank tier (Brigadier-equivalent), so that already covers "ACOS or above." There are two identical copies of this filter in the screen (initial load and the Refresh button) — both are given in full below.
- Open NewsletterPack.
- Select the screen itself (root node), then
OnVisiblein the Properties dropdown. - Find the
ClearCollect(colNewsletterPack, ...)block near the top and replace the whole formula with this.
Set(varNewsletterTargetDate, DateAdd(Today(), Mod(5 - Weekday(Today()) + 7, 7), "Days"));
Refresh('Policy Proof Tracker');
ClearCollect(
colNewsletterPack,
Sort(
AddColumns(
Filter(
'Policy Proof Tracker',
'Planned Publish Date' >= varNewsletterTargetDate &&
'Planned Publish Date' < DateAdd(varNewsletterTargetDate, 1, "Days") &&
(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &&
Published = false &&
'External consultation required' = false
),
SortKey,
If(
'Top Item',
-1000,
Coalesce(LookUp(colChoiceColors, ChoiceValue = 'Document Type'.Value, SortOrder), 99)
),
IsFinalApproved,
Or(
'Approved For Release By'.Value = "XO",
'Approved For Release By'.Value = "ACOS",
'Approved For Release By'.Value = "DCOMD",
'Approved For Release By'.Value = "D Commander"
),
PackTitle,
Coalesce('Title for Newsletter', Title),
PackAudience,
Coalesce(Audience, ""),
PackSummary,
Coalesce('Item summary', "")
),
SortKey,
SortOrder.Ascending
)
)
- Find btnRefresh_1 (the "Refresh" button on the same screen). It has an identical copy of the same formula.
- Select
OnSelectin the Properties dropdown, select all, and replace with this formula.
Set(varNewsletterTargetDate, DateAdd(Today(), Mod(5 - Weekday(Today()) + 7, 7), "Days"));
Refresh('Policy Proof Tracker');
ClearCollect(
colNewsletterPack,
Sort(
AddColumns(
Filter(
'Policy Proof Tracker',
'Planned Publish Date' >= varNewsletterTargetDate &&
'Planned Publish Date' < DateAdd(varNewsletterTargetDate, 1, "Days") &&
(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &&
Published = false &&
'External consultation required' = false
),
SortKey,
If(
'Top Item',
-1000,
Coalesce(LookUp(colChoiceColors, ChoiceValue = 'Document Type'.Value, SortOrder), 99)
),
IsFinalApproved,
Or(
'Approved For Release By'.Value = "XO",
'Approved For Release By'.Value = "ACOS",
'Approved For Release By'.Value = "DCOMD",
'Approved For Release By'.Value = "D Commander"
),
PackTitle,
Coalesce('Title for Newsletter', Title),
PackAudience,
Coalesce(Audience, ""),
PackSummary,
Coalesce('Item summary', "")
),
SortKey,
SortOrder.Ascending
)
)
Fix 3 - Deadline Warning Banner Flashing On Close
ViewItem · property edit · visual only, no data risk
Reported 2026-08-13: clicking Close on an item with a release date inside 10 days (not High Priority, not External Consultation) briefly flashed the amber "Release date is within 10 days" banner before navigating away. The first guide tried reordering Navigate() before the state resets, but that is not enough: Power Apps can still evaluate the old screen for a frame while statements after Navigate() run. Correct fix: add a close-in-progress guard, make the warning/top bar respect it, and set the guard on both close paths.
- Open ViewItem.
- Select the screen itself, then select
OnVisible. - Add this line near the top, immediately after the existing first
Set(varLoadingLinks, ...)line.
Set(varClosingViewItem, false);
- Select conWarningBar1.
- Select
Visible, select all, and replace with this formula.
!Coalesce(varClosingViewItem, false) && varSelectPolicy <> "Filled" && DateDiff(Today(), dpkPublishDate1.SelectedDate, "Days") >= 0 && DateDiff(Today(), dpkPublishDate1.SelectedDate, "Days") < 10 && !ckbHighPriority1.Value && !ckbExtConsult1.Value
- Select conTopBar1.
- Select
Visible, select all, and replace with this formula.
!(
!Coalesce(varClosingViewItem, false) &&
varSelectPolicy <> "Filled" &&
DateDiff(Today(), dpkPublishDate1.SelectedDate, "Days") >= 0 &&
DateDiff(Today(), dpkPublishDate1.SelectedDate, "Days") < 10 &&
!ckbHighPriority1.Value &&
!ckbExtConsult1.Value
)
- Select btnClose1 (the top-right Close button).
- Select
OnSelect, select all, and replace with this formula.
If(
varUnsavedChanges,
UpdateContext({locDisplayDiscardPopUp: true}),
Set(varClosingViewItem, true);
If(varSourceScreen = "Historic", Navigate(Historic, ScreenTransition.Fade), Navigate(Main, ScreenTransition.Fade));
Set(varSelectPolicy, "Empty");
Set(varSelectedRelease, Blank());
Set(varUnsavedChanges, false);
Set(varShowLinkModal, false)
)
- Select btnModalAction1_2 in the Unsaved Changes modal (the button that confirms closing without saving).
- Select
OnSelect, select all, and replace with this formula.
UpdateContext({locDisplayDiscardPopUp: false});
Set(varClosingViewItem, true);
Set(varSelectPolicy, "Empty");
Set(varSelectedRelease, Blank());
Set(varUnsavedChanges, false);
Set(varShowLinkModal, false);
If(varSourceScreen = "Historic", Navigate(Historic, ScreenTransition.Fade), Navigate(Main, ScreenTransition.Fade))
Fix 4 - Newsletter Treats Blank Consultation As Unticked
NewsletterPack · property edit · changes which items appear in the pack
Confirmed by the urgent diagnostic on 2026-08-13: three records matched the Thursday date window, but colNewsletterPack only contained one. The two missing records had finalApprovalOK=true and publishedOK=true, but externalOK=false. The consultation gate must stay: consultation-ticked items should not appear in the newsletter. The safer fix is to keep that rule but make it blank-safe, because a SharePoint Yes/No field can come through as blank rather than explicit false. This uses Coalesce('External consultation required', false) = false, which includes blank/unticked records and still excludes real true.
- Open NewsletterPack.
- Select the screen itself (root node), then select
OnVisiblein the Properties dropdown. - Select all and replace with this full formula.
Set(varNewsletterTargetDate, DateAdd(Today(), Mod(5 - Weekday(Today()) + 7, 7), "Days"));
Refresh('Policy Proof Tracker');
ClearCollect(
colNewsletterPack,
Sort(
AddColumns(
Filter(
'Policy Proof Tracker',
'Planned Publish Date' >= varNewsletterTargetDate &&
'Planned Publish Date' < DateAdd(varNewsletterTargetDate, 1, "Days") &&
(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &&
Published = false &&
Coalesce('External consultation required', false) = false
),
SortKey,
If(
'Top Item',
-1000,
Coalesce(LookUp(colChoiceColors, ChoiceValue = 'Document Type'.Value, SortOrder), 99)
),
IsFinalApproved,
Or(
'Approved For Release By'.Value = "XO",
'Approved For Release By'.Value = "ACOS",
'Approved For Release By'.Value = "DCOMD",
'Approved For Release By'.Value = "D Commander"
),
PackTitle,
Coalesce('Title for Newsletter', Title),
PackAudience,
Coalesce(Audience, ""),
PackSummary,
Coalesce('Item summary', "")
),
SortKey,
SortOrder.Ascending
)
)
- Select btnRefresh_1 on the same screen.
- Select
OnSelect, select all, and replace with this formula too.
Set(varNewsletterTargetDate, DateAdd(Today(), Mod(5 - Weekday(Today()) + 7, 7), "Days"));
Refresh('Policy Proof Tracker');
ClearCollect(
colNewsletterPack,
Sort(
AddColumns(
Filter(
'Policy Proof Tracker',
'Planned Publish Date' >= varNewsletterTargetDate &&
'Planned Publish Date' < DateAdd(varNewsletterTargetDate, 1, "Days") &&
(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &&
Published = false &&
Coalesce('External consultation required', false) = false
),
SortKey,
If(
'Top Item',
-1000,
Coalesce(LookUp(colChoiceColors, ChoiceValue = 'Document Type'.Value, SortOrder), 99)
),
IsFinalApproved,
Or(
'Approved For Release By'.Value = "XO",
'Approved For Release By'.Value = "ACOS",
'Approved For Release By'.Value = "DCOMD",
'Approved For Release By'.Value = "D Commander"
),
PackTitle,
Coalesce('Title for Newsletter', Title),
PackAudience,
Coalesce(Audience, ""),
PackSummary,
Coalesce('Item summary', "")
),
SortKey,
SortOrder.Ascending
)
)
colNewsletterPack rows = 3. If they are genuinely ticked for consultation, they should still stay out of the newsletter.
Fix 5 - Thursday Batch 1/2 Email Drafting (New Feature)
NewsletterPack · new controls + property edit · adds two buttons, does not remove anything
Added 2026-08-15. Two new buttons in the "Email-ready format" panel, Thursday Batch 1 Email and Thursday Batch 2 Email, that build an HTML draft via the Office 365 Outlook connector's DraftEmail action — subject auto-dated, body has this week's newsletter items as a real bold bullet list plus a fixed footer (Previous Newsletters / About / recipient list, copied verbatim from the real sent email and never changing), and BCC pulled from the same BM Groups / BM Memberships SharePoint lists Branch Contact Groups already uses, filtered to whichever Thursday batch the button is for. One manual step remains inside each drafted email: paste this week's real release link over the placeholder text, and set the OFFICIAL sensitivity label before sending — MOD's Purview label can't be set by this connector.
Office365Outlook.DraftEmail is the connector's draft-creation action — nothing in this feature calls SendEmailV2 or SendDraftEmail. Clicking either button puts an unsent draft in the clicking user's own Outlook Drafts folder (the connector connection is per-user, confirmed live with two different mailboxes) and stops there. You still have to open it and press Send yourself.
BM Groups and BM Memberships as data sources in this app (Data pane → Add data → SharePoint → same site Branch Contact Groups uses), and confirm Office 365 Outlook is added as a data source too (each user needs their own connection/sign-in the first time they use the buttons — that's what makes the draft land in the right mailbox).
- Open NewsletterPack.
- Select the screen itself (root node), then
OnVisiblein the Properties dropdown. - Select all and replace with this full formula — it's the existing formula with five new lines appended after the
colNewsletterPackblock.
Set(varNewsletterTargetDate, DateAdd(Today(), Mod(5 - Weekday(Today()) + 7, 7), "Days"));
Refresh('Policy Proof Tracker');
ClearCollect(
colNewsletterPack,
Sort(
AddColumns(
Filter(
'Policy Proof Tracker',
'Planned Publish Date' >= varNewsletterTargetDate &&
'Planned Publish Date' < DateAdd(varNewsletterTargetDate, 1, "Days") &&
(
'Approved For Release By'.Value = "XO" ||
'Approved For Release By'.Value = "ACOS" ||
'Approved For Release By'.Value = "DCOMD" ||
'Approved For Release By'.Value = "D Commander"
) &&
Published = false &&
Coalesce('External consultation required', false) = false
),
SortKey,
If(
'Top Item',
-1000,
Coalesce(LookUp(colChoiceColors, ChoiceValue = 'Document Type'.Value, SortOrder), 99)
),
IsFinalApproved,
Or(
'Approved For Release By'.Value = "XO",
'Approved For Release By'.Value = "ACOS",
'Approved For Release By'.Value = "DCOMD",
'Approved For Release By'.Value = "D Commander"
),
PackTitle,
Coalesce('Title for Newsletter', Title),
PackAudience,
Coalesce(Audience, ""),
PackSummary,
Coalesce('Item summary', "")
),
SortKey,
SortOrder.Ascending
)
);
ClearCollect(colBatchGroups, AddColumns(Sort('BM Groups', SortOrder, SortOrder.Ascending), Ticked, false));
ClearCollect(colBatchMemberships, Filter('BM Memberships', false));
ForAll(colBatchGroups As grp, Collect(colBatchMemberships, Filter('BM Memberships', GroupName = grp.Title)));
Set(varNewsletterSubject, Text(Today(), "yyyymmdd") & " - Cadets Branch weekly policy updates");
Set(
varNewsletterBodyLead,
"Good afternoon all,<br><br>" &
"Please find a link to this week's releases here - <a href=""PASTE-THIS-WEEKS-LINK-HERE"">PASTE THIS WEEK'S LINK TEXT HERE</a><br>" &
"Below is a summary of this week's releases from Cadets Branch:<br><br>"
);
Set(
varNewsletterBodyStatic,
"<br><b>Previous Newsletters:</b><br>" &
"All the previous weekly policy updates are available via the links below<br>" &
"MODNet users: <a href=""https://modgovuk.sharepoint.com/teams/1598/SitePages/Weekly-Policy-Updates---Archive.aspx"">Weekly Policy Updates (sharepoint.com)</a><br>" &
"Resource Centre users: Navigate to: Westminster " & Char(8594) & " Resource Centre " & Char(8594) & " Organisation " & Char(8594) & " Cadets Branch Weekly Policy Updates<br><br>" &
"<b>About the Newsletter:</b><br>" &
"This newsletter works on both MODNet and personal systems, and all policies included will also be uploaded on to both MODNet and the Resource Centre for routine accessing.<br>" &
"Each week we will send out a version of this email, to the usual recipients, providing a link to the latest policy newsletter and a summary of what items have been included.<br>" &
"This email has been sent to the groups listed below but please feel free to forward on as you deem necessary, emailed recipients:<br><br>" &
"ACF CEOs (ex-HQ SE)<br>" &
"JMC SO2's<br>" &
"JMC OC CTT's<br>" &
"---<br>" &
"JMC Cadets Branch 0mailboxes<br>" &
"JMC CTT 0mailboxes<br>" &
"JMC Col Cadets (including Col Ashley Fulford)<br>" &
"JMC RAL members<br>" &
"JMC SCEOs<br>" &
"Cadets Branch<br>" &
"CTC Frimley<br>" &
"CCAT<br>" &
"CRFCA (Sam Plant and Simon Estick)<br>" &
"ACCT UK (Murdo Urquhart and Richard Walton)<br>" &
"CCRS (Shooting Manager - Daf Marston)<br>" &
"CCF RAF & RN leads"
)
- Select btnRefresh_1 on the same screen (it has its own separate copy of the same formula — same trap as Fix 2/Fix 4 above).
- Select
OnSelect, select all, and replace with the exact same formula as above.
- Duplicate the existing btnCopyAll_1 button twice (select it, Ctrl+C, Ctrl+V twice) — this gives you the right base styling (Classic/Button, rounded corners, bold text) without retyping every colour property.
- Rename the two copies btnDraftBatch1_1 and btnDraftBatch2_1 (right-click → Rename, in the tree view).
- Position them in a new row under Copy All:
Y = 56for both,X = 20for Batch 1,X = 32 + (Parent.Width - 52) / 2for Batch 2,Width = (Parent.Width - 52) / 2for both. - Set
Textto"Thursday Batch 1 Email"/"Thursday Batch 2 Email". - Set
BorderColor,FilltoRGBA(46, 110, 145, 1),HoverBorderColor/HoverFill/PressedBorderColor/PressedFilltoRGBA(34, 88, 118, 1)— this is the same blue already used for Thursday Batch controls in Branch Contact Groups, kept consistent across both apps. - Set each button's
OnSelectto the matching formula below.
Set(varBatch1Recipients, Distinct(Filter(colBatchMemberships As mem, CountRows(Filter(colBatchGroups As grp, Lower(Trim(grp.ThursdayBatch.Value)) = "batch 1" && Lower(Trim(grp.Title)) = Lower(Trim(mem.GroupName)))) > 0), Email));
Set(varBatch1Bcc, Concat(varBatch1Recipients, Value, "; "));
If(
CountRows(colNewsletterPack) = 0,
Notify("No newsletter items for this Thursday - nothing to draft.", NotificationType.Warning),
CountRows(varBatch1Recipients) = 0,
Notify("No recipients found for Thursday Batch 1.", NotificationType.Warning),
Office365Outlook.DraftEmail(
"",
varNewsletterSubject,
varNewsletterBodyLead & Concat(colNewsletterPack, Char(8226) & " <b>" & PackTitle & "</b><br> " & Char(9702) & " Intended audience: " & PackAudience & "<br><br>") & varNewsletterBodyStatic,
{Bcc: varBatch1Bcc}
);
Notify("Thursday Batch 1 draft created - check Outlook Drafts.", NotificationType.Success)
)
Set(varBatch2Recipients, Distinct(Filter(colBatchMemberships As mem, CountRows(Filter(colBatchGroups As grp, Lower(Trim(grp.ThursdayBatch.Value)) = "batch 2" && Lower(Trim(grp.Title)) = Lower(Trim(mem.GroupName)))) > 0), Email));
Set(varBatch2Bcc, Concat(varBatch2Recipients, Value, "; "));
If(
CountRows(colNewsletterPack) = 0,
Notify("No newsletter items for this Thursday - nothing to draft.", NotificationType.Warning),
CountRows(varBatch2Recipients) = 0,
Notify("No recipients found for Thursday Batch 2.", NotificationType.Warning),
Office365Outlook.DraftEmail(
"",
varNewsletterSubject,
varNewsletterBodyLead & Concat(colNewsletterPack, Char(8226) & " <b>" & PackTitle & "</b><br> " & Char(9702) & " Intended audience: " & PackAudience & "<br><br>") & varNewsletterBodyStatic,
{Bcc: varBatch2Bcc}
);
Notify("Thursday Batch 2 draft created - check Outlook Drafts.", NotificationType.Success)
)