{
  "apiVersion": 64,
  "label": "OpportunityLineItem Currency Autofill From Pricebook",
  "description": "When OpportunityLineItem.PricebookEntryId is set directly without a Product2Id, stamp CurrencyIsoCode from the selected PricebookEntry. OpportunityLineItem.CurrencyIsoCode has a metadata default of USD, so the Edit Products flow can otherwise save a USD line item for a non-USD Opportunity even though the PricebookEntry lookup is correctly scoped to the Opportunity currency. Runs at triggerOrder 25 before Product2 / UnitPrice autofill, and leaves Product2-driven rows alone so the reverse PricebookEntry resolver can honor user-selected currency changes.",
  "status": "Active",
  "processType": "AutoLaunchedFlow",
  "runAtomically": true,
  "start": {
    "triggerOrder": 25,
    "locationX": 0,
    "locationY": 0,
    "object": "OpportunityLineItem",
    "triggerType": "RecordBeforeSave",
    "recordTriggerType": "CreateAndUpdate",
    "connector": {
      "targetReference": "Has_PricebookEntry"
    }
  },
  "decisions": [
    {
      "name": "Has_PricebookEntry",
      "label": "Has PricebookEntry",
      "locationX": 0,
      "locationY": 0,
      "defaultConnectorLabel": "Default Outcome",
      "rules": [
        {
          "name": "Yes",
          "conditionLogic": "and",
          "conditions": [
            {
              "leftValueReference": "$Record.PricebookEntryId",
              "operator": "IsNull",
              "rightValue": {
                "booleanValue": false
              }
            },
            {
              "leftValueReference": "$Record.Product2Id",
              "operator": "IsNull",
              "rightValue": {
                "booleanValue": true
              }
            }
          ],
          "connector": {
            "targetReference": "Get_PricebookEntry"
          },
          "label": "Yes"
        }
      ]
    }
  ],
  "recordLookups": [
    {
      "name": "Get_PricebookEntry",
      "label": "Get PricebookEntry",
      "locationX": 0,
      "locationY": 0,
      "assignNullValuesIfNoRecordsFound": false,
      "connector": {
        "targetReference": "Stamp_Currency"
      },
      "filterLogic": "and",
      "filters": [
        {
          "field": "Id",
          "operator": "EqualTo",
          "value": {
            "elementReference": "$Record.PricebookEntryId"
          }
        }
      ],
      "getFirstRecordOnly": true,
      "object": "PricebookEntry",
      "storeOutputAutomatically": true
    }
  ],
  "assignments": [
    {
      "name": "Stamp_Currency",
      "label": "Stamp Currency",
      "locationX": 0,
      "locationY": 0,
      "assignmentItems": [
        {
          "assignToReference": "$Record.CurrencyIsoCode",
          "operator": "Assign",
          "value": {
            "elementReference": "Get_PricebookEntry.CurrencyIsoCode"
          }
        }
      ]
    }
  ]
}
