{
  "apiVersion": 64,
  "label": "Opportunity Pricebook Default",
  "description": "On Opportunity create, when Pricebook2Id is null, default it to the active Pricebook2 named 'Standard Price Book'. Without a Pricebook2Id on the Opportunity, the OpportunityLineItem.PricebookEntryId runtime_scoped_lookup resolves WHERE Pricebook2Id = null and returns zero rows, which empties the PBE picker on the New Opportunity Line Item form. The PBE validator scopes by parent Pricebook2Id only; Product2/Currency-specific resolution is handled by the OpportunityLineItem reverse resolver so currency edits can transition from the old PBE to the new matching PBE. Runs at triggerOrder 50 on Create only so existing Opportunities and explicit user-set pricebooks are preserved.",
  "status": "Active",
  "processType": "AutoLaunchedFlow",
  "runAtomically": true,
  "start": {
    "triggerOrder": 50,
    "locationX": 0,
    "locationY": 0,
    "object": "Opportunity",
    "triggerType": "RecordBeforeSave",
    "recordTriggerType": "Create",
    "connector": {
      "targetReference": "Needs_Default_Pricebook"
    }
  },
  "decisions": [
    {
      "name": "Needs_Default_Pricebook",
      "label": "Needs Default Pricebook",
      "locationX": 0,
      "locationY": 0,
      "defaultConnectorLabel": "Default Outcome",
      "rules": [
        {
          "name": "Yes",
          "conditionLogic": "and",
          "conditions": [
            {
              "leftValueReference": "$Record.Pricebook2Id",
              "operator": "IsNull",
              "rightValue": {
                "booleanValue": true
              }
            }
          ],
          "connector": {
            "targetReference": "Get_Standard_Pricebook"
          },
          "label": "Yes"
        }
      ]
    }
  ],
  "recordLookups": [
    {
      "name": "Get_Standard_Pricebook",
      "label": "Get Standard Pricebook",
      "locationX": 0,
      "locationY": 0,
      "assignNullValuesIfNoRecordsFound": false,
      "connector": {
        "targetReference": "Stamp_Pricebook2Id"
      },
      "filterLogic": "and",
      "filters": [
        {
          "field": "Name",
          "operator": "EqualTo",
          "value": {
            "stringValue": "Standard Price Book"
          }
        },
        {
          "field": "IsActive",
          "operator": "EqualTo",
          "value": {
            "booleanValue": true
          }
        }
      ],
      "getFirstRecordOnly": true,
      "object": "Pricebook2",
      "storeOutputAutomatically": true
    }
  ],
  "assignments": [
    {
      "name": "Stamp_Pricebook2Id",
      "label": "Stamp Pricebook2Id",
      "locationX": 0,
      "locationY": 0,
      "assignmentItems": [
        {
          "assignToReference": "$Record.Pricebook2Id",
          "operator": "Assign",
          "value": {
            "elementReference": "Get_Standard_Pricebook.Id"
          }
        }
      ]
    }
  ]
}
