# RenewLock install runbook

Written so a person, or a person's AI assistant, can run it. Every step is safe to repeat. Nothing here needs a password typed anywhere but Microsoft's own sign-in page, and nothing leaves your tenant.

## Who can do this
- A **SharePoint Administrator** for step 2 (app catalog). The first visit to Manage apps on a tenant that has no app catalog creates one automatically at /sites/appcatalog (a few minutes' wait).
- Someone with **Maker** rights in the target Power Platform environment for step 4 (usually any licensed user in the default environment).
- A **site owner** for steps 1 and 3 (site, lists and home page) if you use the in-page setup instead of the script.
- Global Admin is not required. A Dataverse database is required for Path A (the solution import) and most environments have one; Path B (the legacy flow package) needs none. If Solutions shows "No database found", either a Global Administrator or Power Platform Administrator creates the database once, or take Path B (see step 4). RenewLock stores nothing in Dataverse.

## Three ways to run it
1. **In-page setup (no script).** Enable the app once (step 2), add the RenewLock web part to a page, click **Set up this site**. Then do step 4. About 25 minutes the first time.
2. **Script.** `Install-RenewLock.ps1` does steps 1 to 4 in one go. Needs PowerShell 7 and an Entra app ID for PnP PowerShell (`-ClientId`; an admin registers it once with `Register-PnPEntraIDAppForInteractiveLogin`). It installs PnP.PowerShell and the Power Platform CLI on first run, shows its plan, asks for `yes`, and writes a transcript. Pass `-TimeZone "Central Standard Time"` or similar; the default is Eastern. Pass `-Currency EUR` (any three-letter ISO 4217 code) for money in another currency; the default is USD. On a site that already has RenewLock, both keep the site's own value unless you pass them. Its step 4 (`pac solution import`) is Path A and needs a Dataverse database in the target environment, the same as the manual solution import; on an environment without one it finishes steps 1 to 3, prints the Path B instructions and stops, and you import the flows by hand with Path B (re-run with `-SkipFlows` if you ever need the script again); see step 4.
3. **AI-assisted.** Point your agent (Claude Code, GitHub Copilot agent mode, or similar) at `skill/SKILL.md`. The agent runs the script steps one at a time, explains each, and stops for you at consent, the app catalog upload, the Dataverse database or Path B if the environment has none, and the connections. It never handles your password.

Step 4 (the flows) has two paths; all three ways end on one of them, and both need the same five connections (SharePoint, Microsoft Teams, Office 365 Outlook, Office 365 Users, Office 365 Groups).
- **Path A (primary): solution import.** Power Automate → Solutions → Import solution with `JRMRenewalGuard_<version>.zip`. Needs a Dataverse database in the environment. The site URL is set once in the environment variable, the connections are connection references, and upgrades are clean (import the new version over the old).
- **Path B (fallback when Solutions says "No database found"): legacy flow package.** My flows → Import → Import Package (Legacy) with `RenewLock-flows-<site>.zip`, built for your site on https://www.renewlock.com/install#path-b or with `solution/tools/gen_legacy_package.py`. Needs no Dataverse database. The site URL is baked in (one package per site), the importing user owns the flows, upgrades mean importing the new package again and choosing "Update" for each flow, Microsoft labels the import "Legacy", and there is no environment variable and no connection reference. Takes about as long as Path A (5 to 10 minutes including connections).

## Steps

### 1. Site and lists
Create a SharePoint site: SharePoint start page (dismiss any "Explore SharePoint" dialog) → Build → "Site" card → Select a site template → Communication site tab → Standard communication → Preview site template → Use template → Set up your site (name "RenewLock" or any name; wait for "The site address is available") → Create site → "Your site is ready!" → Go to site. There is no "Create site" button on the new start page; close the "Next steps" panel if it appears. Either run the in-page setup from the web part, or apply `RenewLock.template.xml` with PnP:
```powershell
Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/RenewLock -Interactive
Invoke-PnPSiteTemplate -Path .\RenewLock.template.xml
```
Result: lists Renewals, Checkpoints, Milestones, Settings, with views, formatting and defaults.

### 2. App catalog (SharePoint Administrator)
In the SharePoint admin center open More features → Apps → Open; this lands on Manage apps (the `#/manageApps` shortcut can error with "Something went wrong"). On a tenant with no app catalog yet, the first Open silently creates one at /sites/appcatalog and shows "Creating the site for storing apps. This might take a few minutes"; wait, then reload. Upload `RenewLock.sppkg`, select the new row (RenewLock, 1.0.0.24, Disabled) and click **Enable**. In the **Confirm data access** panel keep "Enable this app and add it to all sites" selected, untick **Add to Teams** unless you want a Teams app (it is ticked by default), click **Confirm**, then **Close** on "This app has been enabled". The row then reads Enabled, Added to all sites: Yes. Classic catalog: Deploy with "Make this solution available to all sites in the organization" checked. Or:
```powershell
Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/appcatalog -Interactive
Add-PnPApp -Path .\RenewLock.sppkg -Scope Tenant -Overwrite -Publish -SkipFeatureDeployment
```
Optional: in Manage apps, select RenewLock and choose **Add to Teams** so it appears as a Teams app (the **Confirm data access** panel offers the same as a checkbox, ticked by default).

### 3. Dashboard on the site
Edit the site's home page, meaning the page that opens at the site address (on the Standard communication template that is TopicHome.aspx, not Home.aspx; if the dashboard ends up on another page: Site contents → Site Pages → select it → Make homepage). If "Can't edit this page. Please try again later." appears, Close, reload and click Edit again), click + below the banner, choose One column, click the section, search the right-hand Toolbox pane for "RenewLock" and add the **RenewLock dashboard** web part. There is no Republish button: click **Save as draft**, reload the page, then **Publish changes** (toast "Page published."). The published page shows the "Set up RenewLock on this site" card; click **Set up this site** and confirm with **Yes, create the lists**. The dashboard appears once setup is done. Or:
```powershell
Add-PnPPageWebPart -Page Home -Component "RenewLock dashboard" -Section 1 -Column 1
```

### 4. Flows (Maker in the environment)
Open Power Automate from the Microsoft 365 app launcher of the target tenant, or use the direct link `https://make.powerautomate.com/environments/Default-<tenant id>/solutions` (make.powerautomate.com on its own opens in whichever organisation the browser last used and has no account switcher). Confirm the account menu top right shows your organisation and the environment picker shows "<Org> (default)". Then take Path A or Path B; both need the same five connections, and RenewLock stores nothing in Dataverse either way.

**Path A (primary): solution import.** Needs a Dataverse database in the environment; the database only holds the solution. Most tenants already have one; a brand-new tenant may not. If Solutions shows "No database found" with only a **Create a database** button and no Import solution command, either a Global Administrator or Power Platform Administrator clicks **Create a database** once (it takes a few minutes; reload and carry on with Path A), or take Path B below. Import `JRMRenewalGuard_<version>.zip` in Power Automate → Solutions → Import solution. When asked for the environment variable **RenewLock site**, enter the site URL from step 1. On the Connections step pick or create one connection each for SharePoint, Microsoft Teams, Office 365 Outlook, Office 365 Users and Office 365 Groups, using the account that should run the flows (a service account is best). Finish the import, then turn on RL-Engine, RL-Prompt and RL-Rollover. If a Microsoft 365 group with a team will own renewals, add that same account to the team as a member, so the card can be posted in the team's General channel (see Group owners below). Or:
```powershell
pac auth create
pac solution import --path .\JRMRenewalGuard_1_0_0_10.zip --settings-file .\settings.json --activate-plugins
```
where settings.json sets `jrm_RG_SiteUrl` to the site URL. `pac solution import` also stops on an environment without a Dataverse database; have an admin create it first, as above, or take Path B.

**Path B (fallback): legacy flow package, no Dataverse database.** Use it when Solutions says "No database found" and nobody will create a database. First build the package for your site: open https://www.renewlock.com/install#path-b, paste the site URL from step 1 into the box **Your RenewLock site URL** and click **Download flows package**; the browser builds `RenewLock-flows-<site>.zip` with the site URL baked into the three flows (nothing is sent anywhere). The kit's `solution/tools/gen_legacy_package.py <site url> <out.zip>` builds the same zip from the command line. Then import it: Power Automate (same tenant check as above) → My flows → Import → Import Package (Legacy) → Upload → pick the zip. The wizard shows **Review Package Content**: three flows with Import setup "Create as new", and five Related resources (SharePoint, Microsoft Teams, Office 365 Outlook, Office 365 Users, Office 365 Groups) marked with a red (!) and "Select during import". For each one: click the wrench under Action, click **Refresh list**, click the connection row (your account), click **Save**; the row then shows your account. If the list says "No items", create the connection first (a second browser tab keeps the wizard open): Connections → New connection → pick the connector → Create → sign in as the account that should run the flows (the first one asks for sign-in, the rest usually connect silently), then back in the wizard click **Refresh list** again. When all five are mapped, click **Import**; a bar says "Importing your package ... Don't navigate away" for one to two minutes, then "All package resources were successfully imported." The flows arrive turned OFF (the My flows list shows a small no-entry badge on each flow icon): open RL-Engine, RL-Prompt and RL-Rollover in turn and click **Turn on**. Trade-offs, stated plainly: the site URL is baked in, so one package per site; the importing user owns the flows; upgrades mean importing the new package again and choosing "Update" for each flow; Microsoft labels the import "Legacy"; there is no environment variable and no connection reference. Timing is about the same as Path A (5 to 10 minutes including connections). The web part's Setup card (1.0.0.20) points to Path B from its "No database found" step.

### 5. First run
In Power Automate open RL-Engine and click **Run** → **Run flow** (same on both paths). The run history shows Succeeded in under 10 seconds, and after a refresh the dashboard header shows **Flows connected**. Click **Import CSV** on the dashboard to bring in an existing tracker, or add renewals by hand in the Renewals list.

## Pop-ups you will see, and what to click
- **Confirm data access** (after selecting the uploaded row in Manage apps and clicking Enable): "This app gets data from: SharePoint." Keep "Enable this app and add it to all sites" selected (the default), untick "Add to Teams" unless you want a Teams app (ticked by default), click Confirm; then "This app has been enabled" → Close. No API-access approval appears; the package requests none.
- **Set up this site** (web part): no browser pop-up. The card asks "Create the four RenewLock lists on <site>?" with **Yes, create the lists** / Back; a progress bar then runs for one to two minutes and logs "Created list Milestones / Settings / Renewals / Checkpoints"; it ends with a green bar "Lists are ready on <site>. Nothing else was changed." followed by the Step 2 and Step 3 instructions in the card.
- **Import solution, Connections step** (Path A): five rows (SharePoint, Microsoft Teams, Office 365 Outlook, Office 365 Users, Office 365 Groups). Pick an existing connection or New connection; a Microsoft sign-in window opens; sign in as the flow-running account; click Accept on the permissions page; green ticks; Next.
- **Import solution, Environment variables step** (Path A): one box, RenewLock site; paste the site URL; Import. A yellow "Currently importing" bar runs one to three minutes; keep the tab open.
- **Import Package (Legacy), Review Package Content** (Path B): three flows with Import setup "Create as new" and five Related resources (SharePoint, Microsoft Teams, Office 365 Outlook, Office 365 Users, Office 365 Groups) with a red (!) and "Select during import". For each: wrench under Action → **Refresh list** → the connection row with your account → **Save**; the row then shows your account. "No items" means that connection does not exist yet: Connections → New connection → pick the connector → Create → sign in as the flow-running account (the first one asks for sign-in, the rest usually connect silently), then Refresh list again. With all five mapped, **Import**; a bar reads "Importing your package ... Don't navigate away" for one to two minutes, then "All package resources were successfully imported." Keep the tab open.
- **Flows arrive turned off** (Path B): the My flows list shows a small no-entry badge on each flow icon. Open RL-Engine, RL-Prompt and RL-Rollover and click **Turn on** in each.
- **Script path**: a Microsoft sign-in window per connection (admin center, site, app catalog) and once a "Permissions requested" page for the PnP app that an admin accepts; then a browser sign-in for the Power Platform CLI. The script prints a line before each one opens and asks you to type yes before it changes anything. On an environment without a Dataverse database it stops at `pac solution import` after steps 1 to 3 and prints the Path B instructions; either create the database first (step 4, Path A) and re-run, or import the flows by hand with Path B.

## What a human must do, always
- Grant consent to PnP PowerShell the first time it signs in (only if you use the script).
- Upload to the app catalog (SharePoint Administrator).
- Decide at "No database found": create the Dataverse database once (Global Administrator or Power Platform Administrator; only on an environment that never had one) and take Path A, or take Path B, which needs no database.
- Create the five connections and sign in for them (whoever will run the flows): on Path A in the Import solution Connections step; on Path B under Connections → New connection (the first one asks for sign-in, the rest usually connect silently), then map each Related resource in the Import Package (Legacy) wizard. Same five connectors either way.
- Turn the flows on (on Path B they always arrive turned off).
- For each Microsoft 365 group with a team that owns renewals: add the flow-running account to that team (a team owner or a Teams admin does this).

## Time zone
Countdown days, the digest day and message dates follow the `TimeZone` value in the Settings list (Windows name, default Eastern Standard Time). Set it before the first engine run. The daily trigger itself runs at 6:00 AM Eastern.

## Currency
Money in the dashboard, Teams cards, emails and the weekly digest follows the `Currency` value in the Settings list: a three-letter ISO 4217 code such as USD, EUR, GBP, CAD or AUD (default USD; blank also means USD). The browser installer offers a picker and the script takes `-Currency`; on the in-page path edit the `Currency` item in Settings. The SharePoint list columns keep their own currency format. The optional **Fee if it lapses** column (`LapseFee`) uses the same currency; opaque mode hides all money.

## Group owners
Owner and Backup owner can be a person or a group: a Microsoft 365 group (with or without a team), a security group, or a SharePoint group of the RenewLock site. The supervisor is always one person. A group with a team gets the card in its General channel (anyone in the team can answer; the first answer counts) plus an email to the group. Any other group gets one email (to the group's address, or to the members when it has none) and a short Teams message to each member, up to `GroupMessageLimit` in the Settings list (default 10; bigger groups get the email only). If nobody in the group can be reached, the checkpoint escalates on the next engine run. Before you pick a group:
1. Give the group edit access to the RenewLock site: Settings → Site permissions → Share site, add the group as a member. Without it, members cannot answer in the dashboard.
2. If the group has a team, add the account that runs the flows to that team. Without it the card cannot reach the channel, and RenewLock sends the email and Teams messages instead.
3. For a SharePoint group, let everyone see its members: Group settings → Who can view the membership of the group: Everyone.

## Checks
- Dashboard shows "Flows connected" after the first engine run. "Flows stale" means the engine has not run for more than 30 hours; check the flow's run history.
- The Checkpoints list gains a row for every prompt sent.
- Settings list holds `EngineHeartbeat`, `SchemaVersion` (2026.10.17 for this release), `FlowsVersion` (2026.10.17, written by RL-Engine on every run), `Currency` and `GroupMessageLimit`.
- On Renewals, List settings → Owner and Backup owner show "Allow selection of: People and Groups"; on Checkpoints, Assignee does too.
- Power Automate → Connections shows five connections for the flow-running account: SharePoint, Microsoft Teams, Office 365 Outlook, Office 365 Users and Office 365 Groups.

## Upgrade
Re-run the same steps with the new files. Setup and the template only add what is missing (and, when a release needs it, change a column's settings); your records are never touched. Path A: solution import upgrades in place; connections and the site URL are kept. Path B: build a new package for the site (Download flows package on the install page again, or `gen_legacy_package.py`), import it from My flows → Import → Import Package (Legacy), and on Review Package Content choose "Update" for each of the three flows instead of "Create as new"; map the five connections as before, import as the same user (the importing user owns the flows), and check each flow is still turned on afterwards.

### Upgrading an existing site to 2026.10.17 (in this order)
1. **Package.** Upload the new `RenewLock.sppkg` (1.0.0.24) in Manage apps and enable it, or let the script do it. The dashboard's **Update lists** button comes with it.
2. **Lists first.** Click **Update lists** on the dashboard (a site owner), or re-run the browser installer or the script. This adds Fee if it lapses (`LapseFee`), Delivered to and Nobody reachable, seeds `Currency` and `GroupMessageLimit`, and lets Owner, Backup owner and Assignee accept groups (existing values are kept). `SchemaVersion` becomes 2026.10.17 only when nothing failed; otherwise Update lists stays offered and its log names the column to change by hand (List settings → the column → Allow selection of: People and Groups).
3. **Then the reminders.** Path A: import `JRMRenewalGuard_1_0_0_10.zip` over the old solution; the Connections step now asks for a fifth connection, **Office 365 Groups**: create it with the flow-running account like the other four. Path B: build a new package, import it and choose "Update" for each flow; there are now five Related resources, and the new one is Office 365 Groups (create it under Connections → New connection if the list says "No items").
4. **Run RL-Engine once.** `Settings.FlowsVersion` then reads 2026.10.17. Until the reminders are updated, a checkpoint owned by a group skips to the backup owner and then the supervisor, and the dashboard shows a warning.
5. **Group owners.** Add the flow-running account to each team whose group owns renewals (see Group owners above).

## Uninstall
Turn off and delete the three flows: Path A, delete the solution (or the flows inside it); Path B, in Power Automate → My flows delete RL-Engine, RL-Prompt and RL-Rollover, signed in as the user who imported them (that user owns them). Then remove the app from the site and the app catalog, delete or keep the four lists. Nothing else was installed. The five connections stay under Connections on either path; delete them there if nothing else uses them. If step 2 created the app catalog site or step 4 created the Dataverse database (Path A only), those are tenant features that stay; neither holds anything of RenewLock's once the package and flows are gone.
