> ## Documentation Index
> Fetch the complete documentation index at: https://human-resource-docs.ha-consultancy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflow Setup

> How the extension registers approval workflow categories, templates, and event handlers — and what to verify if HR workflow templates don't appear.

The extension hooks into BC's standard **Workflow** framework to make three HR documents approvable: **Overtime Journal**, **Salary Advance**, and **Loan Application**. Everything below happens automatically — this page exists to demystify what was registered and to give you a checklist when something doesn't appear where you expect it.

## What the extension registers

On install (and on every upgrade), `Workflow Setup Event HAC` (Codeunit `70003105`) subscribes to four standard BC workflow events and adds:

### Three workflow categories

| Code  | Description      |
| ----- | ---------------- |
| `OTJ` | Overtime Journal |
| `SAD` | Salary Advance   |
| `LAP` | Loan Application |

Categories are filters in the **Workflow Templates** page that let you find HR templates quickly.

### Three workflow templates

| Code | Description                        | Category |
| ---- | ---------------------------------- | -------- |
| `OJ` | Overtime Journal Approval Workflow | `OTJ`    |
| `SA` | Salary Advance Approval Workflow   | `SAD`    |
| `LA` | Loan Application Approval Workflow | `LAP`    |

Templates are read-only blueprints. To use one, you select it from **Workflow Templates** and click **New Workflow from Template** — that copies it into the active **Workflows** list where you can edit conditions and approvers.

### Table-to-Approval relations

A relation between the `Over Time Journal HAC` table and the standard `Approval Entry` table is inserted, so that approval entries can be looked up from the document and vice versa.

### Event-response predecessors

Five workflow events are registered for each of the three documents (send-for-approval, set-status-to-pending, cancel-all-approvals, open-document, create-approval-requests). This is the plumbing that lets the BC workflow engine know which response code to fire when one of the HR documents emits an approval event.

## When this runs

| Trigger                                   | Behaviour                                                                                 |
| ----------------------------------------- | ----------------------------------------------------------------------------------------- |
| First install of the extension            | All categories, templates, and event subscriptions are registered automatically           |
| Upgrade to a new version                  | The `Upgrade Codeunit HAC` re-runs the install steps so any missing items are back-filled |
| New company created in an existing tenant | The `OnInstallAppPerCompany` trigger fires, repeating the registration                    |

You should never need to run this manually.

## Approval User Setup

The workflow templates are useless until you have at least one **Approval User Setup** record. This is standard BC, not part of the extension, but it is a hard prerequisite.

1. Open **Tell Me** → **Approval User Setup**.
2. Click **New** and fill in:
   * **User ID** — the BC user who can approve
   * **Approver ID** — who approves on this user's behalf when their own approval is needed
   * **Approval Administrator** — tick for at least one user (often the HR manager)
   * **Salesperson Code** / **Substitute** — optional
3. Repeat for every user who will appear as an approver in HR workflows.

Without these records, sending a document for approval throws *"Approver ID must have a value in Approval User Setup"*.

## Linking the workflow to a user

Each HR document type also relies on the employee's **Direct Manager** to know whom to route the approval to. Verify on every employee card:

* **Direct Manager** is filled in.
* **Related User** is filled in — this is the BC user account that will receive approvals on the dashboard.

See [Approvals](/features/approvals) for the end-to-end walkthrough.

## Troubleshooting

| Symptom                                                      | What to check                                                                                                                    |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| HR workflow templates don't appear in **Workflow Templates** | Open **Workflow Setup** and click **Recreate Approval Workflow Templates**. The HR template registration runs again.             |
| *"Approver ID must have a value"* on send-for-approval       | Approval User Setup is missing for that user — see above.                                                                        |
| Document goes to approval but no notification appears        | The approver's **Related User** is blank on their employee card, or the approver isn't logged into BC with the matching user ID. |
| *"You cannot create more than one workflow…"*                | A workflow with the same code is already active. Either edit the existing one or copy the template under a different code.       |
| Approval cancels itself immediately                          | Conditions on the workflow exclude the document — open the workflow and review the **When Event** filter.                        |

## Object reference

| Object                              | ID       | Notes                                                                                                                       |
| ----------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| Codeunit `Workflow Setup Event HAC` | 70003105 | Registers categories, templates, table relations, event predecessors                                                        |
| Codeunit `ApprovalMgtHAC`           | —        | Holds the HR-specific approval event codes (`RunWorkflowOnSend…ForApprovalCode`, `RunWorkflowOnCancel…ApprovalRequestCode`) |
| Codeunit `Install Codeunit HAC`     | 70003100 | Indirect — runs on install, doesn't touch workflow itself but is the entry point                                            |
| Codeunit `Upgrade Codeunit HAC`     | 70003101 | Indirect — runs on upgrade; workflow templates are re-inserted via the standard BC `OnInsertWorkflowTemplates` event        |

## Related pages

* [Approvals](/features/approvals) — end-user walkthrough for setting up and running HR approvals
* [First-Time Configuration](/getting-started/configure) — high-level setup overview
