Account protection
Give each company one owner, protect new owners for a set time, and let only managers move accounts.
The Account protection plugin (account-protection) gives each company one owner. A company is identified by its country and registration number. A new owner gets a protection window. The owner loses the account if they log no qualifying contact in time, or when the window ends. Only managers and admins can change an account's owner, and every change is recorded.
For what reps and managers see, see Account protection for users.
The plugin ships with NextCRM but is not installed. Nothing changes until an admin installs it.
Install
Go to Administration → Plugins and open Account protection.
Check the settings. Plan the first contact deadline before you install (see First cycle after install).
Review Requested permissions: accounts:read, accounts:write, activities:read, users:read and notify. Tick I grant these permissions.
Click Install. The plugin is enabled right away, and a background job indexes the existing accounts.
For enabling, disabling and uninstalling plugins in general, see Plugins.
Settings
| Setting | Default | Effect |
|---|---|---|
protectionDays | 90 | Length of the protection window in days, counted from the moment the owner was set. Minimum 1. |
contactDays | 30 | Days the owner has to log a qualifying contact. Minimum 1. If it is larger than protectionDays, protectionDays is used, so there is no separate contact check. |
contactTypes | visit,meeting | Comma-separated activity types that count as a qualifying contact. Valid types: call, meeting, note, email, visit. Unknown names are ignored. A value with no valid type cannot be saved. If one is stored anyway, visit,meeting is used. |
warnDays | 7 | How many days ahead the Expiring protection page looks. |
defaultCountry | CZ | Two-letter country code used when an account's Billing country is empty or not recognised. |
requireNumber | false | When on, users with the user role must enter an Account ID when they create an account. Managers and admins are not affected. Edits are not checked. |
orderMonths | 12 | Protection runs at least this many months from the last confirmed order (status Confirmed, Delivered, Invoiced or Paid). 0 turns this off; orders still count as contact. |
Changes to protectionDays and contactDays apply to new protection windows only. Existing windows keep their dates. The other settings apply from the next check.
How a company is identified
The plugin builds a number key from two account fields:
- Account ID, with spaces removed and in upper case. An account without an Account ID has no key and is not protected.
- Billing country. It accepts a two-letter code (
CZ) or a country name in English, Czech, German or Ukrainian ("Czechia", "Česko", "Tschechien"). If it is empty or not recognised,defaultCountryis used.
For Czech companies, numbers of up to 8 digits are padded with leading zeros, so 1234567 and 01234567 are the same company.
Two foreign companies with the same number and an unrecognised country can end up with the same key. Check the conflicts list for such cases.
Leads have no registration-number field, so the plugin applies to accounts only.
Protection windows
A protection window (a registration) starts when an account with a number key gets an owner:
- a user creates the account with Assigned to set (the new account form fills in the creator);
- a manager or admin sets or changes the owner;
- someone adds an Account ID to an account that already has an owner;
- the plugin is installed and the account already has an owner;
- the account takes over a number from another account (see Conflicts);
- the plugin is enabled again (see Disable and uninstall).
Each window has two dates:
- Contact deadline: start +
contactDays. - Protected until: start +
protectionDays.
A daily job runs at 06:00 UTC. For each account whose date has passed:
- At the contact deadline, it looks for a qualifying contact. If it finds one, the account stays protected until the Protected until date. If not, the owner is removed. The history reason is "no contact in time".
- At the Protected until date, the owner is removed. The history reason is "protection expired". A contact does not extend the window.
The owner is removed in the first daily run after the date, so an account can keep its owner for up to a day longer.
After a run that removed owners, all active managers and admins get one email, "{count} accounts lost their protection", with the account names. No email is sent when nothing was removed.
To give an account a new window, a manager assigns an owner again. Any owner change ends the old window and starts a new one for the new owner. Editing the Account ID or Billing country does not restart the window.
Qualifying contact
An activity counts as a qualifying contact when it:
- is linked to the account,
- has the status Completed,
- has a type listed in
contactTypes, - has a date on or after the day the window started.
Activities logged on contacts or opportunities only count if they are also linked to the account. Scheduled and cancelled activities never count. A Visit starts as Scheduled in the activity form, so reps must set it to Completed.
Orders
A confirmed order (status Confirmed, Delivered, Invoiced or Paid) on the account keeps it protected until at least the order date plus orderMonths, and never shortens the window. A confirmed order also counts as the qualifying contact when it is dated on or after the day the window started, or when it still extends protection (for example, a new owner takes over a customer who ordered recently). Draft, pending, ready, sent, cancelled and failed orders do not count, so entering an order and cancelling it before it is confirmed does nothing. A confirmed order that is cancelled later stops extending the window, but the contact it provided stays. When the order that set the date is cancelled, protection falls back to the previous confirmed order or to the window itself. The daily job checks orders again before it removes an owner, and a new owner of an ordering customer keeps the order-based date.
The plugin reads orders with the orders:read permission, granted automatically from plugin version 0.2.0. If orders cannot be read, they are ignored and a warning is logged.
Owner changes
Users with the user role cannot change Assigned to on an existing account. The save is rejected with "Only a manager can change the account owner." This also applies to their MCP tokens.
Managers, admins, background jobs and plugins can change the owner.
A user can still choose any owner when they create an account. Only changes to existing accounts are restricted.
Every owner change is written to the account's Owner history on the Protection tab: date, previous owner, new owner, who made the change ("system" for jobs) and the reason. Reasons are "created", "assigned", "released", "protection expired", "no contact in time" and "plugin installed".
Duplicates
When someone creates an account, or changes an account's Account ID or Billing country, and the number key belongs to another account, the save is rejected. This applies to every role, including managers and admins. The message depends on the case:
| Case | Message |
|---|---|
| The user already owns the other account | "You already have this company in the CRM." |
| The other account is protected | "This company is protected until {until}." |
| The other account is not protected, user role | "This company is already in the CRM. A manager has been asked to assign it to you." |
| The other account is not protected, manager or admin | "This company is already in the CRM." |
The message never names the owner or shows the other account's data.
The rules run on every account write: the app's forms, MCP tools, API routes, background jobs and other plugins. MCP clients get RULE_REJECTED with the same message. If the check fails or takes longer than 500 ms, the save is blocked with the core "rule unavailable" message, and the error goes to the plugin log.
Manager notices
When a user with the user role is blocked by a duplicate (and does not own the other account), the plugin queues a notice. A job sends queued notices every 5 minutes to all active managers and admins:
- Blocked: {account} is protected when the other account is protected.
- Assign {account} when the other account has no protection. The manager can assign it to the rep.
Each email names the account and the rep. Each blocked attempt sends its own email. A notice that cannot be sent is retried on the next run and dropped after 24 hours, with an error in the plugin log.
All plugin emails are in English.
Expiring protection page
Managers and admins see Plugins → Expiring protection in the sidebar. The page has two lists:
- Due within {days} days: accounts whose next date (contact deadline or Protected until) falls within
warnDays. It can still list a contact deadline that is already met until the next daily run checks it. - Freed in the last 7 days: accounts whose owner the daily job removed.
Users with the user role do not see the menu item or the page.
Conflicts
Two accounts can share a number key:
- On install, when existing accounts share a number. The oldest account (by creation date) keeps the number.
- When two users create the same company at the same moment.
The account that keeps the number is protected as usual. The other account gets no protection window.
The plugin page under Administration → Plugins shows Accounts sharing a registration number with the columns Number, Account and Kept by. Resolve each case by hand, for example by merging the data into one account and deleting the other, or by correcting the Account ID or Billing country of the wrong one.
- When you correct or clear the duplicate's Account ID or Billing country, its row leaves the list. With a new number that no other account holds, it keeps that number.
- When the account that keeps the number is deleted, or its Account ID or Billing country changes, the duplicate takes over the number and its row leaves the list. If it has an owner, a fresh window starts for that owner at that moment.
- When the duplicate is deleted, its row leaves the list.
The daily job also re-checks the list and removes rows that no longer apply.
Background jobs
The plugin registers these Inngest functions. They run only while the plugin is enabled.
| Function | Schedule | Does |
|---|---|---|
plugin-account-protection-cron-expire | Daily at 06:00 UTC | Checks contact deadlines and protection windows, removes owners, emails managers. Re-checks the conflicts list. Clears "freed" entries older than 7 days. |
plugin-account-protection-cron-notices | Every 5 minutes | Sends queued manager notices. |
plugin-account-protection-after | On account create, update and delete; on order create and update | Indexes numbers, starts and ends windows, writes owner history, recomputes protection from confirmed orders. |
The install backfill runs once in plugin-lifecycle-install. One account that fails in the daily job is logged and retried in the next run; the others are processed.
See Background jobs.
First cycle after install
Install starts a window for every account that has an owner and an Account ID, all dated on the install day. Contacts logged before that day do not count. Any account without a completed visit or meeting by day contactDays loses its owner in that day's run.
Before you install, either ask reps to log their visits right after install, or raise contactDays for the first cycle and lower it later. Lowering it later affects only new windows.
Disable and uninstall
Disable turns off the rules, jobs, tab, panel, page and menu item. Stored data is kept. Nobody loses an owner while the plugin is disabled.
When you enable it again, the plugin catches up before it removes any owner. Its jobs notice that they have not run for more than an hour (the notice job runs every 5 minutes, so this happens within minutes of enabling). For each account it tracks:
- If the owner was changed while the plugin was disabled, the change is added to the Owner history (reason "assigned" or "released", made by "system") and a fresh window starts for the new owner.
- If the contact deadline or the Protected until date passed while the plugin was disabled, the window starts again from that moment, because the owner had no chance to keep it.
Number changes made while the plugin was disabled are picked up on the account's next edit. The same catch-up runs after the job server was down for more than an hour.
Uninstall deletes everything the plugin stored: windows, owner history, conflicts and queued notices, plus the plugin log. Accounts keep their current owners. Use Download data (JSON) first if you need the owner history. A new install starts from scratch with a fresh backfill.
Limits
- An account write is sent to the plugin in the background. If the job server is unreachable at that moment, the account is not indexed until its next edit.
- For up to a day after a window ends, the duplicate message can still show "protected until" with a past date.
- Owner changes made to an account in quick succession can be recorded as one change.