Data model and case generation
Retail Store Audit Operations uses two record types—Store Audit Case and Audit Task—and generates them in a deliberate two-step flow: a Plan Author publishes an audit plan and then explicitly triggers generation, which creates one Store Audit Case per selected Retail Organization and one or more Audit Tasks per case.
Record types
The application introduces two tables. No custom fields are added in V1—both rely on inherited fields from their parent tables.
| Display name | sys_name | Extends | Number prefix |
|---|---|---|---|
| Store Audit Case | sn_rtl_store_audit_case |
sn_retail_case |
SAC |
| Audit Task | wm_audit_task |
wm_task |
SACTK |
Key data relationships:
- Store Audit Case → Retail Organization:
requesting_service_organizationholds the store (auditee) being audited;service_organizationholds the fulfilling organization. - Audit Task → Store Audit Case: The inherited
wm_task.initiated_fromfield references the parent Store Audit Case. - Work Order → Audit Task: One
wm_orderis created perwm_audit_taskby a before-insert Business Rule. Thewm_tasktable requires a parentwm_orderto insert successfully. - Template Item → Retail Organization: Managed via the existing
platform table
sn_case_creation_service_org—no custom junction table is needed.
Record lifecycle states
Store Audit Case: New → Open → Closed
Audit Task active states (the Close Complete button is visible): Draft, Pending Dispatch, Scheduled, Assigned, Accepted, Work In Progress. Terminal state: Closed Complete.
Generation trigger
Generation is separated from publication by design. Publishing a plan makes it available for generation but does not create records. The Plan Author must explicitly click Generate Cases/Tasks to commit to record creation.
The Generate Cases/Tasks UI Action is visible on the
sn_task_plan_template form only when:
- The plan is in Published state.
- The user has the
sn_rtl_store_audit.plan_authorrole.
Generation completes synchronously—all records exist before the Plan Author sees confirmation.
What generation creates
For each Retail Organization selected on the plan, the system creates:
- One Store Audit Case in state New, linked to the Retail Organization
via
requesting_service_organization. - One or more Audit Tasks per case, based on the plan's Template Item
Configurations, each linked to the parent case via
wm_task.initiated_from. - One Work Order per Audit Task, created by the before-insert Business Rule immediately before the task record inserts.
Generation architecture
The UI Action calls the platform API
sn_task_plan.MultiEntityCreationService
.applyTaskTemplateForMultipleEntities(), which delegates to the
sn_retail.RetailTaskPlanTemplateHelperEP extension point
implemented by this application. The extension point configures one Store Audit Case
and its Audit Tasks per Retail Organization;
MultiEntityCreationService inserts the records; and three Business
Rules on wm_audit_task complete the WM lifecycle setup.
| Business Rule | Trigger | Purpose |
|---|---|---|
| Create WO — Audit Task | Before insert | Creates one wm_order per task, sets the parent
reference before insertion, and syncs description fields on
update. |
| Assign work_configuration | Before insert | Sets wm_work_configuration to Retail Audit
default when the field is empty. |
| Qualify WO — Audit Task | After insert | Calls AuditTaskService.qualifyWorkOrder() to activate
the Work Order–task link in the WM state machine. |
Track plan tab
After generation, a Track plan related-list tab appears on the plan record, listing all generated Store Audit Cases with case number, created date, due date, and state. The tab is hidden until at least one case has been generated.