> **Source:** https://knowledge.leegality.com/document-execution/workflows/v4/rule-engine/how-to/make-a-field-mandatory > **Site:** Leegality Knowledge Base — https://knowledge.leegality.com > **About:** Leegality is a document execution platform covering eSigning, stamps, NeSL, workflows, and REST API integration. > **Navigation:** Every article on this site has a plain-text version at `.txt` (this format). To get an index of all articles with their `.txt` links, read: https://knowledge.leegality.com/llms.txt > **AI Guide:** For instructions on how to navigate this knowledge base as an AI agent, read: https://knowledge.leegality.com/ai-readable.txt --- # Make a field mandatory with a rule **Goal:** a field must be filled — but only when another field's value says so. Working example: *FATCA Declaration is mandatory when Customer Type = NRI; residents can leave it blank.* This is a [Mandatory rule](https://knowledge.leegality.com/document-execution/workflows/v4/rule-engine/rule-categories#a--mandatory-rules), and it ships the way mandatory rules typically do: as a **validation at Proceed** — the rule checks the field when the user clicks Proceed and blocks the stage with an error naming exactly what's missing. ## The spec ``` TARGET field: FATCA Declaration (pack-level custom field) ACTION: Set Mandatory = true SUBJECT field: Customer Type (pack-level custom field, Dropdown: NRI / Resident) CONDITION: Customer Type = NRI OUTCOME: NRI runs cannot Proceed with FATCA empty (error shown); Resident runs proceed freely with FATCA blank Workflow: (yours) ``` ## The rule logic This assumes both custom fields are added at **pack level**, with API names `customerType` and `fatcaDeclaration`: ``` #version 2.0 var customerType = pack.lecf_customerType; if(customerType != null && (isEmpty(customerType) == false)) { if(customerType == "NRI") { var fatca = pack.lecf_fatcaDeclaration; if(fatca == null || isEmpty(fatca)) { throw "FATCA Declaration is mandatory for NRI customers"; } } } ``` Reading it against the spec: the rule reads the Subject Field, checks the Condition (`== "NRI"`), and enforces the Target by throwing the error only when the field is empty **and** the condition holds. Below/outside the condition, the rule does nothing — that's the OUTCOME's other side. ## Adapt these parts | Part | In the logic | Change it to | | --- | --- | --- | | Subject Field | `pack.lecf_customerType` | `lecf_` + your field's exact API name | | Condition value | `"NRI"` | The exact dropdown option, spelled as configured | | Target Field | `pack.lecf_fatcaDeclaration` | `lecf_` + the field being made mandatory | | Error message | `"FATCA Declaration is mandatory for NRI customers"` | Your message, word for word — it's part of the spec | For a **numeric** condition instead of a dropdown match (mandatory above a threshold), the comparison needs a number conversion — that variant is the [Build your first rule](https://knowledge.leegality.com/document-execution/workflows/v4/rule-engine/build-your-first-rule) tutorial, end to end. If your fields live at **document or invitee level** rather than pack level, the paths differ — send the spec to [support@leegality.com](mailto:support@leegality.com) or see Advanced: LEEQL for the data model. ## Configure it 1. Rule Engine panel → new rule → **Rule Title**: `FATCA mandatory for NRI customers`. 2. Paste the adapted logic into **Create Rule**. 3. **Trigger Method**: **On Proceed Create** — pack-level fields are completed in the Create stage, so the check belongs on that stage's Proceed. (If your target field is filled on the Invite stage, use **On Proceed Invitee** instead — pick the Proceed of the stage where the field gets filled.) 4. Save. Full configuration flow, step by step: [Build your first rule](https://knowledge.leegality.com/document-execution/workflows/v4/rule-engine/build-your-first-rule). ## Test it — both directions 1. Customer Type = NRI, FATCA empty, Proceed → blocked with your error. 2. Fill FATCA, Proceed → goes through. 3. Customer Type = Resident, FATCA empty, Proceed → goes through, no error. ## Related Mandatory also works in reverse — relaxing a requirement when a condition holds — see [Rule categories](https://knowledge.leegality.com/document-execution/workflows/v4/rule-engine/rule-categories#a--mandatory-rules).