{
  "apiVersion": "63.0",
  "label": "Account Set BillingCountryCode from BillingCountry",
  "description": "Before Account is saved, look up Country_Dictionary__c by Full_Name__c to derive BillingCountryCode from the selected Billing Country.",
  "status": "Active",
  "processType": "AutoLaunchedFlow",
  "start": {
    "triggerOrder": 500,
    "object": "Account",
    "triggerType": "RecordBeforeSave",
    "recordTriggerType": "CreateAndUpdate",
    "filterLogic": "and",
    "filters": [
      {"field": "BillingCountry", "operator": "IsChanged", "value": {"booleanValue": true}},
      {"field": "BillingCountry", "operator": "IsNull", "value": {"booleanValue": false}}
    ],
    "connector": {"targetReference": "Get_Country_Dict"}
  },
  "recordLookups": [
    {
      "name": "Get_Country_Dict",
      "label": "Get Country Dictionary",
      "object": "Country_Dictionary__c",
      "outputReference": "country_dict",
      "filterLogic": "and",
      "filters": [
        {
          "field": "Full_Name__c",
          "operator": "EqualTo",
          "value": {"elementReference": "$Record.BillingCountry"}
        }
      ],
      "getFirstRecordOnly": true,
      "connector": {"targetReference": "Check_Found"},
      "faultConnector": {"targetReference": "Done"}
    }
  ],
  "decisions": [
    {
      "name": "Check_Found",
      "label": "Country found in dictionary?",
      "defaultConnector": {"targetReference": "Done"},
      "defaultConnectorLabel": "Not Found — skip",
      "rules": [
        {
          "name": "Found",
          "label": "Found",
          "conditionLogic": "and",
          "conditions": [
            {"leftValueReference": "country_dict", "operator": "IsNotBlank"}
          ],
          "connector": {"targetReference": "Set_BillingCountryCode"}
        }
      ]
    }
  ],
  "assignments": [
    {
      "name": "Set_BillingCountryCode",
      "label": "Set BillingCountryCode on triggering record",
      "assignmentItems": [
        {
          "assignToReference": "$Record.BillingCountryCode",
          "operator": "Assign",
          "value": {"elementReference": "country_dict.Name"}
        }
      ],
      "connector": {"targetReference": "Done"}
    },
    {
      "name": "Done",
      "label": "Done"
    }
  ]
}
