Automation

Validation rules, flows, scheduled jobs and approvals — the business logic that runs without you.

Automation

Automation is what makes HotCRM do work for you — sending notifications, updating fields, creating tasks, escalating cases, all without anyone clicking a button. Four kinds of automation are available, each suited to a different job.

How HotCRM implements them: validation + field logic run as object hooks (beforeInsert / beforeUpdate); everything multi-step, scheduled, or approval-based runs as flows; and approvals are approval nodes inside a flow (ADR-0019), not a standalone process type. Standalone workflow-rule and approval-process metadata do not exist on the platform either — ADR-0019 and ADR-0020 removed both types.

The four kinds

KindWhen it firesBest for
Validation rulesBefore saveBlocking bad data
FlowsOn screen, on record change, or on a scheduleMulti-step logic, branching, loops, waits, approvals
Scheduled jobsOn a scheduleDaily sweeps, weekly reports
Approval processesInside a flow (approval node)Multi-step sign-off with record locking

Validation rules

The simplest kind. They block a save if a condition is true.

Built-in examples:

  • "End date must be after start date" (on contracts).
  • "List price must be greater than zero" (on products).
  • "A campaign member must have either a Lead or a Contact, not both" (on campaign members).
  • "Discount % must be between 0 and 100" (on quote line items).

To add one — it is a source edit, not a Setup screen. There is no Setup → Object entry: the object roster the Console does show is App Studio → Data Model → Objects, and a rule is a validations[] entry on the object itself (src/*/objects/*.object.ts), next to its fields.

  1. Add a validations[] entry to the object (src/*/objects/*.object.ts).
  2. Write the condition (the fail condition).
  3. Write the error message shown to the user.
  4. Deploy — a rule runs unless it carries active: false.

Flows (multi-step)

Looking for "workflow rules"? There is nothing to look for — not in this app, and not on the platform. ObjectStack retired the standalone workflow-rule type (ADR-0019 / ADR-0020): there is no workflow metadata type, no workflows collection on a stack, and no Workflow Rules entry under App Studio → Automation — only Flows. A "when this record saves, do that" rule is a record-change flow, and every one this app ships is a row in the table below.

When a single field update isn't enough — branching, loops, waits, multi-object writes, approvals — use a flow. A flow is a visual graph of nodes: get data → decide → create/update records → notify → wait → call a sub-flow.

A flow fires one of three ways, set by its start node:

  • Screen — launched manually from a button/action; collects input on a screen.
  • Record change — fires on insert/update (record-after-create / record-after-update).
  • Schedule — runs on a cron schedule. Every flow states its time zone, and each one HotCRM ships runs in UTC: the times in the table below are UTC.

Auto-launch needs the triggers capability. Record-change and scheduled flows only fire when the stack's requires list includes triggers — it installs the record-change + schedule trigger providers (schedule triggers also use the job service). Screen flows are always launched manually.

Built-in flows in HotCRM (50). Each row carries the flow's own label — the name listed under a package's Automations in Studio (New in Studio on the console home page → the package → Customize → Automations), and the name you pick from in App Studio → Developer → Flow Runs, so a run you are chasing can be looked up here verbatim:

FlowTriggerWhat it does
Lead Conversion ProcessScreenConvert a qualified lead into an account + contact (+ optional opportunity), then notify
Copy Lead Revenue to New AccountSubflowCalled by Lead Conversion Process to copy the lead's annual revenue onto the account it has just created, with system privilege
Generate Quote from OpportunityScreenBuild a quote from an opportunity and move it to Proposal
Add Products to Price BookScreenOn a price book, add every active product it does not price yet, at one percentage of its List Price; products it already prices keep their price
Schedule Follow-upScreenCreate the next follow-up task on a lead, already linked to it and owned by the right user
Enroll Members in CampaignScreenBulk-enroll eligible leads or contacts into this campaign, skipping the already-enrolled and the opted-out
Enroll Lead in CampaignSubflowCalled by Enroll Members in Campaign, and by Add to Campaign on a lead, to enroll one lead as the person running it: a lead already on the campaign is skipped, and a person who may not create campaign members is refused
Enroll Contact in CampaignSubflowCalled by Enroll Members in Campaign, and by Add to Campaign on a contact, to enroll one contact as the person running it: a contact already on the campaign is skipped, and a person who may not create campaign members is refused
Escalate CaseScreenCollect an escalation reason, then flag and re-prioritise the case
Stamp Case EscalationSubflowCalled by Escalate Case to write the escalation stamps with system privilege
Close CaseScreenCollect the resolution, then close the case and stop the SLA clock
New Lead Routing & SLARecord change (insert)Stamp a rating-based follow-up SLA and alert the lead's owner (for a standard lead, only when someone else assigned it)
Contact WelcomeRecord change (insert)Prompt the owner to welcome a newly created contact
Urgent Task AlertRecord change (insert)Notify the owner when a task is created at Urgent
Large Deal ApprovalRecord change (insert or update)For an opportunity created or edited at or above the threshold: tiered sign-off via approval nodes — Sales Manager ≥ $100K, Sales Director > $500K
Opportunity Status Change ApprovalRecord change (update)Sign-off a deal needs before it is declared won or lost. Ships switched OFF — it opens nothing until an install arms the gate on the opportunity's Status Change Approval field; armed, the rep sets Requested Status and the stage moves only when the request is approved
Opportunity Qualification ApprovalRecord change (update)The qualification (立项) sign-off a new deal needs before its stage or its won/lost call may change. Ships switched OFF — it opens nothing until an install arms the gate on the opportunity's Qualification Approval field; armed, the rep ticks Request Qualification Approval, and everything else on the deal stays editable while it waits
Lead Conversion ApprovalRecord change (insert)Sign-off a lead needs before it can be converted. Ships switched OFF — it opens nothing until an install arms the gate on the lead's Conversion Approval field
Account ApprovalRecord change (insert)Sign-off a newly created account needs before it counts as established data. Ships switched ON — a new account starts Pending and is decided in the approval inbox, except one Convert Lead creates, which is not submitted (on a deployment without approvals it stays blank and editable instead); an install that wants no account sign-off sets the default on the account's Approval Status field to Approved
Large Deal Won AlertRecord change (update)When an opportunity of $100K or more turns Closed Won, notify the owner — the owner alone, not their manager
Accepted Quote Creates an OrderRecord change (update)When a quote becomes Accepted, create a Draft order with the quote's header and lines, once per quote. Ships switched ON; see Switching a packaged flow
Accepted Quote Drafts a ContractRecord change (update)When a quote becomes Accepted, draft its contract (a 12-month Subscription at the quote's total) and name it on the quote's order — what every accepted quote did before this release. Ships switched OFF; see Switching a packaged flow
Draft Contract from OrderScreenDraft Contract on an order: draft the order's contract and name it on the order; refused when the order is cancelled, names a contract already or has no contact
Draft Contract from Order (write)SubflowCalled by Draft Contract from Order to create the contract and name it on the order, with system privilege
Contract Drafted NoticeRecord change (insert)When a contract is drafted — from an accepted quote or by Draft Contract on an order — tell the person whose act drafted it in the app, with a link to the contract
Billing Hand-off: Closed WonRecord change (update)On the transition into Closed Won, enqueue one durable POST of the deal + account + line items to the billing endpoint
Billing Hand-off: Contract ActivatedRecord change (update)On the transition into Activated, enqueue one durable POST of the contract + account + the originating deal's line items
Quote Printed → PresentedRecord change (insert)When Print Quote files a quote's PDF in its attachments, move a Draft or In Review quote to Presented — the rep's own save, so a quote with no Contact keeps its status. Any other attachment, and a reprint of a quote in any other status, changes nothing
Forecast Owner RenamedRecord change (update)When a user's name changes, write the new name onto every forecast they own in each organization they are a member of, so each forecast's title follows the rename
Case Escalation ProcessRecord change (insert or update)When a case is created at or turns Critical, flag it escalated, hand it to the least-loaded holder of the crm_service_manager position (it stays with its owner while that pool is unstaffed) and notify the agent it came from; escalating also opens an urgent follow-up task for the account owner
Project Initiation ApprovalRecord change (update)When a project is set to In Approval: a Project Director or the PMO approves it, with its budget's version 1, then a Finance Controller too when that version totals 100,000 or more. Approved, the project is Approved and the version its baseline; rejected, Rejected; recalled, Draft again
Budget Top-Up ApprovalRecord change (update)When a project's budget version 2 or later is set to In Approval: a Project Director or the PMO approves it, then a Finance Controller too when it raises the Approved Budget by 10 % or more. Approved, the version is the project's new baseline; rejected, Rejected; recalled, Draft again
Timesheet ApprovalRecord change (insert or update)When a timesheet is Submitted, or created already submitted: its approver, the project manager, decides in the Inbox, and its hours count in the project's cost only once approved. Nobody approves their own, and a recall puts it back to Draft
Project Member Person RenamedRecord change (update)When a user's name changes, write the new name onto every project staffing row of theirs in each organization they are a member of, so each row's title follows the rename
Order Contract Follows to Its RowsRecord change (update)When an order's contract is set, changed or cleared (with Draft Contract, or by editing its Contract), move the order's plan steps, invoices and payments that carried the previous contract to the new one, or clear them with it, and give those that name none the new contract, so each contract's totals count the order's records; a record that names any other contract stays
Confirmed Order Gets a Payment PlanRecord change (update)When an order becomes Confirmed and has no payment plan, create one step with system privilege: the order's total, planned for today plus the order's payment terms (Due on Receipt, or no terms, today). An order that already has a plan gets none
Payment Plan Follows the Order AmountRecord change (update)When an order's total changes and the order has exactly one plan step with nothing received, set that step's planned amount to the new total, with system privilege; otherwise the plan is left alone and the order shows Payment Plan Differs
Expense Report ApprovalRecord change (update)When an expense report with no project is Submitted: the spender's manager decides (the Finance Controllers when there is none), then a Finance Controller too for a total of 2,000 or more. Approved, Approved; rejected, Rejected; recalled, Draft again. Its expenses follow the report
Project Expense Report ApprovalRecord change (update)When an expense report on a project is Submitted: the project's manager decides, then a Finance Controller too for a total of 2,000 or more, and its expenses count in the project's cost once approved. A report on a Closed, Cancelled or locked project never gets here: a validation rule refuses its submission with the reason, and it stays in Draft. Should one be submitted all the same (the project closed or was locked in the same instant), the flow puts it back to Draft and tells its spender why in the Inbox
Travel Request ApprovalRecord change (insert or update)When a travel request with no project is Submitted, or created already submitted: the traveler's manager decides (the Finance Controllers when there is none), in one step. Approved, Approved; rejected, Rejected; recalled, Draft again
Project Travel Request ApprovalRecord change (insert or update)When a travel request on a project is Submitted, or created already submitted: the project's manager decides, in one step (an administrator when the project has none, or the trip is theirs). Approved, Approved; rejected, Rejected; recalled, Draft again
Project Budget AlertRecord change (update)When a project's Budget Status crosses into Warning (80 %) or Exceeded (100 %), notify its project manager and every Finance Controller once, proposing Lock Time and Expenses
Contract Auto-ExpirationSchedule (daily midnight)Expire activated contracts past their end_date and notify the owner
Quote Auto-ExpirationSchedule (daily 1 AM)Expire quotes past their expiration_date that are still open
Campaign Auto-CompletionSchedule (daily 2 AM)Mark in-progress campaigns whose end_date has passed as Completed
Forecast SnapshotSchedule (daily 3 AM)Upsert a current-quarter forecast row per active opportunity owner — pipeline, best case, commit and closed-won totals
Stalled Deal AlertSchedule (daily 7:30 AM)Nudge owners about open opportunities stuck in a stage too long
Contract Renewal ReminderSchedule (daily 8 AM)Open renewal tasks/opportunities for contracts nearing their end_date
Case SLA MonitorSchedule (hourly)Flag and escalate open cases past their SLA due date
Task Due ReminderSchedule (hourly)Notify owners of tasks whose reminder time has arrived

A row marked (insert or update) is one flow that runs both when a record is created and when it is edited later, under one name in Flow Runs (its trigger is record-after-write). Earlier releases shipped these five as pairs, the second flow labelled (on create); runs recorded under those retired names stay in Flow Runs as history, and new runs are recorded under the surviving name.

Seeded demo records get their owner from the platform, not from a flow: when the seed data finishes loading, the platform hands every seeded record that has no owner to the first administrator. HotCRM's former Demo Bootstrap flow, which re-checked for ownerless records every ten minutes, has been retired.

Notifications inside flows are delivered by the notify node (inbox + email via the messaging service) — not the legacy script/email step, which is a no-op in 7.4.

See Developers › Extending Objects if you need to build new flows.

Scheduled automation

Time-based automation is implemented as scheduled flows — flows whose start node carries a cron schedule. The eight Schedule rows above are the complete set; there is no separate scheduled-job metadata to look for. They run via the job service, so the triggers capability is paired with job (both ship in the default slate).

From ObjectStack 17.5.0, scheduled flows are off until the deployment turns them on. The platform runs package-authored scheduled work only when the deployment sets OS_AUTOMATION_SCHEDULED_WORK_ENABLED=true (1, on and yes also count). Without it, none of the eight flows above runs — no contract or quote expiry, no SLA monitor, no reminders, no forecast snapshots — and os doctor prints the effective value. Under the isolated tenancy posture a scheduled flow must also name the organization it acts as; these eight do not, so they are not armed there.

Date-driven field logic that needs no orchestration lives on the object rather than in a scheduled sweep. A default the field can state for itself is declared on the field: a new quote's expiration date is 30 days after its quote date, and a new forecast's snapshot date is today, unless the person saving it enters another date. The rest — freezing an expired/accepted quote, deriving a forecast period — lives in lightweight object hooks (beforeInsert / beforeUpdate).

The division of labour on forecasts is worth calling out, because it is the pattern to copy: the Forecast Snapshot flow decides who gets a snapshot and what the totals are, while the forecast object's hook decides which calendar period the snapshot belongs to. A cron expression can say "every night"; it cannot say "the first day of this quarter", so that boundary is derived once, by the object, for every writer.

Switching a packaged flow

A flow HotCRM ships is read-only in Studio, but an administrator can switch it on or off. On the console home page click New in Studio (Studio opens on a New Package form; close it with Cancel), then the package that ships the flow → Customize → Automations → the flow. Its header reads Switched on for this deployment or Switched off for this deployment, with the switch beside it; a toast confirms each change. The two quote flows below ship in HotCRM Revenue. The switch sends POST /api/v1/automation/<name>/toggle with { "enabled": true } or false, which a script can send too (measured on ObjectStack 18.6.0, in English and Simplified Chinese). The choice belongs to your installation: it is kept across restarts and across upgrades of HotCRM, and it wins over the default the flow ships with. A flow nobody has switched follows that default, so a later version that changes a default moves only installations that never chose.

Two flows decide what accepting a quote creates:

FlowShipsSwitch it when
Accepted Quote Creates an OrderOnOff: you do not use orders, and accepted quotes should create none
Accepted Quote Drafts a ContractOffOn: every accepted quote should draft its contract, as before this release

Restoring the behaviour before this release. Until this release, every accepted quote drafted a contract and none created an order. Switch Accepted Quote Drafts a Contract on to draft the contract again; the drafted contract is exactly the one it used to be, and the quote's order names it. Switch Accepted Quote Creates an Order off as well if you want no orders. Without the contract flow, a rep drafts the contract from the order when the sale needs one (Draft Contract, see Sales › Orders).

Approvals

Since ObjectStack 7.4, approvals are modeled as approval nodes inside a flow (ADR-0019) rather than a standalone approval-process type. On entry the node opens an approval request, locks the record while the step is pending, mirrors the live status onto an approval_status field, and resumes down the approve / reject branch.

HotCRM's built-in Opportunity Approval flow chains two approval nodes for tiered sign-off (manager → director). See Revenue › Approvals for thresholds, what approvers see, and the audit trail. A deal of $100K or more can be closed won only once this flow has approved it, so switching the flow off leaves no way to close such a deal won by hand: the rule cannot tell that the flow is off (see Closing a large deal won).

A second, independent gate — Opportunity Status Change Approval — asks for sign-off before a deal is declared won or lost. It ships switched off and keeps its verdict in its own field, so arming it never changes the amount-based sign-off. A third, Opportunity Qualification Approval, is the qualification (立项) sign-off a new deal needs before its stage or won/lost call may change; it too ships off, and with both armed it comes first. See Sales › Opportunity Qualification.

Order of operations

When a record is saved, the order is fixed:

  1. System runs auto-calculations (formula fields, auto-numbering).
  2. Validation rules run — if any fail, the save is blocked.
  3. The record is saved to the database.
  4. Flow triggers fire — record-after-create or record-after-update, whichever the save was.
  5. notify nodes inside those flows queue their inbox messages and email.

A flow's own writes are ordinary saves, so they re-enter this list and can trigger further flows. There is no fixed re-evaluation budget to rely on: the engine breaks self-trigger loops with a re-entrancy guard — a flow re-entered for the same record while its previous run is still in flight is skipped, and the skip is logged as a warning. Write each record-change flow's start condition so it stops re-firing on its own writes; the guard is a backstop, not a stop condition.

Understanding this order helps debug "why didn't my flow fire?" questions.

Email templates

Most automation actions send email. Templates live in App Studio → Integration → Email Templates and support:

  • Merge fields — {{path.to.value}} placeholders, rendered against the data payload passed on that send. Spell every segment the way HotCRM spells it — objects are crm_opportunity and crm_contact, fields are name, owner_id, email — never Salesforce-style Opportunity.Name. What the path is rooted at depends on the payload shape the sender passes. HotCRM's own notification templates (below) are the shape to copy: each reads flat holes such as {{name}} or {{contract_number}}, filled from the values the flow's notify node passes with it. Declare the names your template reads in its variables list and agree the shape with whoever sends the mail.
  • Conditional blocks — show only if a condition is true.
  • HTML + plain text versions.
  • Attachments — quote PDFs, contract PDFs.

HotCRM ships an email template for each of its own automatic notifications, the alerts its flows send to your colleagues (never to customers): an approval decision on an account, a lead conversion or a large deal; a newly routed or converted lead; a new contact to welcome; a stalled deal or a large one won; a task reminder or an urgent task; a new quote; a contract that has expired or is due for renewal; a case that was escalated or missed its SLA. Each template comes in English, Simplified Chinese, Japanese and Spanish, and every recipient gets the copy in their own language, or in English when the app has none for it. They are records of the platform's email-template object, alongside the platform's own authentication mail (invitations, password resets).

Each notify node in the flows listed above names its template and passes the values the template's holes read, so the subject and body text live in the template, not in the flow: to change the wording, change the template. In the source the templates live in an email-templates/ folder in each package whose flows send them (src/sales/, src/service/ and src/revenue/), one file per language. The alerts that come from scheduled flows go out only where the deployment has switched scheduled work on (see Scheduled automation). Contract activation sends nothing: it runs as an object hook (src/sales/objects/contract.hook.ts) with no notification step, and the contract mail that does go out comes from the Contract Auto-Expiration and Contract Renewal Reminder flows. Author a template in App Studio → Integration → Email Templates when you need a templated outbound email of your own.

Where to monitor automation

  • App Studio → Developer → Flow Runs — pick a flow from the list, then read its recent runs and each run's status (success / failed / running / skipped). Scheduled flows appear here too: they are flows, so there is no separate scheduled-job history to go looking for.
  • Automations, a package's tab in Studio (New in Studio on the console home page, then Customize on the package) — the flow roster itself, when you need to check what a flow is wired to do before reading its runs.
  • Setup → Diagnostics → Audit Log — what changed on a record and who changed it: one entry per save, with its time, the user who saved, and the old and new value of every field the save changed. A field an object hook filled in on the way appears inside the same entry as the save that set it off. It is an administrator's screen: Setup is not among a sales rep's apps and the audit log refuses a rep's reads, so a rep follows a record's changes on the record itself (see Tips for users below).
  • The run's outcome counters — each run also records Records Selected, Records Acted On, Gate Skips and Uncountable Effects, with a per-node breakdown in Run Summary. These are real columns rather than one JSON blob, so you can filter and alert on them. Terminal runs are kept for 30 days.

A green run and a run that did something are not the same thing: a sweep that selects records and then writes none reports success exactly like a sweep with nothing to do. Records Acted On is what separates them. The alert worth wiring is Records Selected > 0 and Records Acted On = 0 and Uncountable Effects = 0, sustained over consecutive runs — that last term is not optional, because a run that reached something the platform cannot count has an incomplete acted count rather than a zero one. On runs recorded before these counters existed the fields are empty, and empty is not 0.

Read one qualifier alongside it, or HotCRM's own sweeps will trip that alert while working perfectly. Stalled Deal Alert and Contract Renewal Reminder re-select the same records every morning and then gate each one on whether it has already been handled, so a steady state of "everything has already been nudged" also reads as selected-but-not-acted. Run Summary tells the two apart: if the run's Already Nudged? / Already Reminded? lookup found the existing tasks, the gate skips are accounted for and the sweep is healthy; if it found none and the gate closed anyway, the skips are unexplained and the gate is the suspect.

A notification a flow sends without a variable its email template requires is not delivered (MISSING_VARIABLES), yet the flow run still reads completed and its notify step a success: the refusal is recorded only on that notification's Notification Delivery record, with Status dead and an Error that names the missing variable, so that is where to look when someone says a notification never arrived.

Tips for admins

  • ✅ Validation rules are the cheapest way to enforce data quality — use them liberally.
  • ✅ One flow per condition is easier to maintain than a mega-flow with 10 branches.
  • ✅ Anything beyond a single field write — branching, multi-object writes, waits, approvals — belongs in a flow rather than an object hook: a flow run is visible in Flow Runs, hook code is not.
  • ✅ Test in sandbox before activating in production — bad automation can cascade fast.
  • ✅ Document what each rule does in its description field — your future self will thank you.

Tips for users

If a record isn't behaving as expected:

  1. Check the record's activity — the Activity card on the record page. Each save adds an entry: a change to a field the app tracks shows its old and new value (Status: New → In Progress), and an edit to other fields shows as a plain Updated entry. It does not say whether a flow or an object hook made the change; ask an admin to read the record's entries in Setup → Diagnostics → Audit Log.
  2. Check the task list — did a flow auto-create a task you missed?
  3. Ask an admin to open App Studio → Developer → Flow Runs and read the recent runs of the flow you expected to fire.

On this page