{
  "apiVersion": 56,
  "label": "Credits — Stamp Approvers on Create",
  "description": "When a Credits record is created, look up the region's three approvers from Region_All__c and stamp them so the approval engine can resolve them on Submit. Stamps at Create (not on Submit) because the engine reads ApproverRelatedField BEFORE the Submit FieldUpdate fires (approval_service.go:487 selectInitialApprovalStep → resolveApproverIDsForNodeWithContext). If approver fields were stamped on Submit, the engine would read NULL and fall back to submittedByID — submitter becomes own approver. Self-sufficient: derives Region via Account__c → Account.Region__c rather than reading $Record.Region__c, so it does not depend on Prefill Flow ordering within the same before-save transaction. If any approver column is missing on Region_All__c, sets Approval_Status__c='NeedsTriage' at create so sales ops list view surfaces the gap before AE attempts submission. Credit_Lifecycle__c 'InApproval' transition is removed (and the picklist value retired) — that intermediate state was tied to the old on-Submit trigger and is redundant with Approval_Status='Pending'. See proposal §7.",
  "processType": "AutoLaunchedFlow",
  "status": "Active",
  "start": {
    "object": "Credits__c",
    "triggerType": "RecordBeforeSave",
    "recordTriggerType": "Create",
    "connector": {"targetReference": "Check_Account_Present"}
  },
  "recordLookups": [
    {
      "name": "Get_Account",
      "label": "Get Account for Region",
      "locationX": 200,
      "locationY": 150,
      "object": "Account",
      "filterLogic": "and",
      "filters": [
        {"field": "Id", "operator": "EqualTo", "value": {"elementReference": "$Record.Account__c"}}
      ],
      "getFirstRecordOnly": true,
      "storeOutputAutomatically": true,
      "assignNullValuesIfNoRecordsFound": false,
      "connector": {"targetReference": "Get_Region_Approvers"}
    },
    {
      "name": "Get_Region_Approvers",
      "label": "Get Region Approvers",
      "locationX": 200,
      "locationY": 250,
      "object": "Region_All__c",
      "filterLogic": "and",
      "filters": [
        {"field": "Region__c", "operator": "EqualTo", "value": {"elementReference": "Get_Account.Region__c"}}
      ],
      "getFirstRecordOnly": true,
      "storeOutputAutomatically": true,
      "assignNullValuesIfNoRecordsFound": false,
      "connector": {"targetReference": "Check_Approvers_Found"}
    }
  ],
  "decisions": [
    {
      "name": "Check_Account_Present",
      "label": "Account linked? (defensive guard)",
      "locationX": 200,
      "locationY": 50,
      "rules": [
        {
          "name": "account_present",
          "label": "Yes — look up region approvers",
          "conditionLogic": "and",
          "conditions": [
            {"leftValueReference": "$Record.Account__c", "operator": "IsNull", "rightValue": {"booleanValue": false}}
          ],
          "connector": {"targetReference": "Get_Account"}
        }
      ],
      "defaultConnectorLabel": "No — terminate (schema required validation will surface the error)"
    },
    {
      "name": "Check_Approvers_Found",
      "label": "Check All Three Approvers Found",
      "locationX": 200,
      "locationY": 350,
      "rules": [
        {
          "name": "all_approvers_present",
          "label": "All approvers present",
          "conditionLogic": "and",
          "conditions": [
            {"leftValueReference": "Get_Region_Approvers", "operator": "IsNull", "rightValue": {"booleanValue": false}},
            {"leftValueReference": "Get_Region_Approvers.Region_Pre_Sales_Manager__c", "operator": "IsNull", "rightValue": {"booleanValue": false}},
            {"leftValueReference": "Get_Region_Approvers.Regional_Finance__c", "operator": "IsNull", "rightValue": {"booleanValue": false}},
            {"leftValueReference": "Get_Region_Approvers.Region_BG_Leader__c", "operator": "IsNull", "rightValue": {"booleanValue": false}}
          ],
          "connector": {"targetReference": "Stamp_Approvers"}
        }
      ],
      "defaultConnector": {"targetReference": "Route_To_NeedsTriage"},
      "defaultConnectorLabel": "Missing approver — route to triage"
    }
  ],
  "assignments": [
    {
      "name": "Stamp_Approvers",
      "label": "Stamp Three Approver User-Lookup Fields",
      "locationX": 100,
      "locationY": 450,
      "assignmentItems": [
        {"assignToReference": "$Record.Presales_Manager_User__c", "operator": "Assign", "value": {"elementReference": "Get_Region_Approvers.Region_Pre_Sales_Manager__c"}},
        {"assignToReference": "$Record.Finance_Approver_User__c", "operator": "Assign", "value": {"elementReference": "Get_Region_Approvers.Regional_Finance__c"}},
        {"assignToReference": "$Record.BG_Leader_User__c", "operator": "Assign", "value": {"elementReference": "Get_Region_Approvers.Region_BG_Leader__c"}},
        {"assignToReference": "$Record.Regional_Ops_User__c", "operator": "Assign", "value": {"elementReference": "Get_Region_Approvers.Region_Ops__c"}}
      ]
    },
    {
      "name": "Route_To_NeedsTriage",
      "label": "Route Credits To NeedsTriage At Create",
      "locationX": 300,
      "locationY": 450,
      "assignmentItems": [
        {"assignToReference": "$Record.Approval_Status__c", "operator": "Assign", "value": {"stringValue": "NeedsTriage"}}
      ]
    }
  ]
}
