Office inbox (`IWorkItemService`)
Updated
A work item is one thing a named person still has to do on a record — finish an activity, win a deal, resolve a case. It is not a BPMN engine, not a role queue, and not a public create API.
From a script#
await GetService<IWorkItemService>().EnsureOpenAsync(new WorkItemDraft
{
Title = activity.Subject,
IdempotencyKey = $"CompleteActivity:{activity.MetaId:D}",
AssigneeUserId = agentUserId,
ActionCommandName = "CompleteActivity",
TargetObjectType = "Document",
TargetObjectName = "Activity",
TargetObjectMetaId = /* Activity metaId */,
RecordId = activity.MetaId,
SourceModel = "CRM",
});
EnsureOpenAsync is idempotent on the Open row with that key. It refuses a
draft that has neither an assignee nor ActionCommandName. A draft with only
ActionCommandName (no assignee) is a leftover command-pool shape: scripts
must not open those for Sales Submit or purchase approval — /inbox will not
show them.
Closing:
CompleteAsync/CancelAsyncby id (the inbox buttons)CompleteBySourceAsync(commandName, recordId)— also runs automatically when that document command succeeds (command journal hook)CancelBySourceAsyncwhen the work is no longer needed
Reassign (personal Open rows only):
await GetService<IWorkItemService>().ReassignAsync(workItemId, toUserId);
POST /api/workitems/{id}/delegate { "userId" } is the same write. Who may:
the current assignee or an administrator. Target must be an existing active,
unlocked MetaUsers row. Rows with no AssigneeUserId return 409. Delegating
does not rewrite Activity.Agent. Same user is a no-op true. Auto-complete
by source command still closes the same row.
A missing or already closed id returns false / 0. Auto-complete never
fails the command.
Inbox visibility#
GET /api/workitems (the /inbox tab, Nova rail). A row is visible when the
current user is the assignee. Execute on ActionCommandName does not list
the row. ?all=1 is Administrators only (leftover unassigned rows included).
There is no HTTP create. Scripts open rows; the SPA lists, completes, cancels,
and delegates personal rows (GET /api/workitems/assignees is the picker —
names only, not the admin user directory).
The assistant's list_inbox / complete_inbox / cancel_inbox /
reassign_inbox tools use the same visibility and gates as this API.
run_command is how it Approves or Completes the source document (Execute
checked inside the tool; ICommandRunner itself does not check).
Who emits#
| Producer | Inbox row |
|---|---|
| CRM Activity / Opportunity / Case / AgentTask | Yes, when the agent has a login (UserId). |
SubmitSalesOrder |
No. The hold is subtype Submitted (journal + Manager phone). |
| Purchase approval | No. The hold is ApprovalThreshold + Execute on Approve. Empty/zero threshold = off. |
Domain events#
In-process IDomainEventSink: document.posted after a successful post,
command.succeeded after a successful command journal row. Handlers that
throw are logged and skipped. No broker. A tenant HTTPS webhook is an
outbox on those same events — enqueue in the posting transaction, HTTP
later — Tenant webhooks. Do not HttpClient from a
handler.
Process timeline#
GET /api/documents/{id}/timeline merges the command journal for that record,
document links either end, and work items on that record — newest first. The
Nova card side panel lists it above related documents. This is not a BPMS and
not the field-audit Activity widget. Running the assistant when
document.posted fires is a separate outbox: assistant on event.
What this is not#
Not Camunda. Not Salesforce Tasks. CRM Activity is the journal of a call or meeting; it opens a work item when the agent has a login user.