CR Notes
This page explains how note reading and note creation work in the Caution Report flow.
For editing an existing note, use CR Update Notes.
API Endpoints
GET /data/caution-report/get-all-notesGET /data/caution-report/by-id/:idPOST /data/caution-report/note/create
Bottom line
The Get All Notes and Get CR Notes flowcharts are both useful, but they describe two different note views in the current implementation:
Get All Notesis a real backend endpoint and returns only top-level CR notes with noactivityIdGet CR Notesis reflected in the CR detail response shape, where activity-linked notes are grouped under each CR activity
So the two note views are both real, but they are not the same API flow.
Purpose
CR notes capture user or system commentary and are shown in two main ways:
- as top-level CR notes
- as activity-linked notes under CR activities
When new notes are created through the portal note form, they are activity-linked and must also synchronize to TMF.
Read path A: Get All Notes
This is the explicit backend endpoint used by the portal notes table.
Confirmed endpoint
GET /data/caution-report/get-all-notes
What it returns
The backend query is intentionally filtered with activityId: IsNull().
That means this endpoint returns:
- notes belonging to the CR
- only notes without an activity link
- newest-first ordering
- paged response with
countanddata
Current portal usage
The CR detail page calls this endpoint in loadCrNotes() and uses it to populate the main notes table.
Read path B: Get CR Notes
In the current codebase, I did not find a separate standalone get-cr-notes controller endpoint for CR.
What I could confirm is that CR detail mapping already splits notes into two buckets:
notesWithoutActivitynotesWithActivity
Then the backend response maps them like this:
- top-level CR response
notesgets notes withoutactivityId - each grouped activity in
activityListgets only the notes whoseactivityIdmatches that activity
So the practical meaning of Get CR Notes in the current implementation is:
- activity-scoped notes shown inside the CR detail activity sections
- not the same thing as the top-level
get-all-notesendpoint
Read behavior summary
| Note view | Current source | What it shows |
|---|---|---|
| Get All Notes | explicit backend endpoint | top-level CR notes with no activity link |
| Get CR Notes | CR detail response mapping | notes attached to a specific CR activity |
Create note flow
When a user creates a note from the CR detail page, the current implementation does not behave like a simple local comment save.
Main flow
| Step | Business meaning |
|---|---|
| load CR and status context | note target must exist |
| save local CR note | local note record is created first |
| find CR activity by CR id + activity id | note must attach to a valid activity |
| build TMF note payload | downstream payload is prepared |
| send note to TMF | external sync happens |
| if TMF fails, delete local note and reject | rollback behavior exists |
| if TMF succeeds, write success audit and return note | create completes |
Confirmed implementation behavior
- portal loads top-level notes from
GET /data/caution-report/get-all-notes - portal creates notes via
POST /data/caution-report/note/create - note form requires both
activityIdandnote - backend requires a matching CR activity for the selected
activityId - backend deletes the just-created local note if TMF note sync fails
Important implementation nuance
There is a useful distinction here for the docs and for onboarding:
- top-level notes are read from the dedicated notes endpoint
- newly created portal notes are activity-linked
- activity-linked notes are later shown inside activity-level note views in the CR detail response
So “all notes” in everyday conversation can sound broader than what the actual get-all-notes endpoint returns.
Flowchart verdict
The note flowcharts are mostly correct, but they should be read as two different views:
Get All Notesmatches the real endpoint-backed top-level note listGet CR Notesmatches the activity-level note grouping visible in CR detail behavior
That is the most accurate code-checked interpretation of the current repo.
Code references
intt-portal/src/app/components/pages/main-modules/cr/cr-details/cr-details.component.tsmvp2-data-service/src/modules/caution-report/caution-report.controller.tsmvp2-data-service/src/modules/caution-report/caution-report.service.tsmvp2-data-service/src/modules/caution-report/caution-report-response.model.ts