{
  "id": "FLOW-004",
  "name": "BeforeSave Update re-derives $Record.PLG_BD_Pool__c on Account switch",
  "description": "Create an Order with AccountId whose PLG_BD_Pool=true (captured by FLOW-003 path), then PATCH the Order to switch AccountId to a second Account with PLG_BD_Pool=false. The BeforeSave flow must re-run on UPDATE and flip Order.PLG_BD_Pool__c from true to false. Locks the BeforeSave-Update arm of the PR #1106 patch (isBeforeSaveFlow marker honored on RecordBeforeUpdate, not just RecordBeforeCreate). Account_PLG_Id is a static Id of a PLG_BD_Pool__c=true Account — update per environment.",
  "variables": {
    "Account_PLG_Id": "0015g00000OmZRxAAN"
  },
  "setup": [
    {
      "type": "http",
      "method": "POST",
      "endpoint": "/services/data/v63.0/sobjects/Order",
      "payload": {
        "AccountId": "{Account_PLG_Id}",
        "EffectiveDate": "2026-04-17",
        "Status": "Draft",
        "StatusCode": "Draft",
        "Name": "FLOW-004-BeforeSaveUpdate",
        "Archived__c": false,
        "Contain_Earlier_Termination_Clause__c": false,
        "CurrencyIsoCode": "USD",
        "Is_Stripe__c": false,
        "IsReductionOrder": false,
        "OP_Paid_via_Marketplace__c": false,
        "Order_Expiration_Alert__c": false,
        "Order_is_Terminated__c": false,
        "Order_to_be_deleted__c": false,
        "PLG_BD_Pool__c": false,
        "TotalAmount": 0
      },
      "expects": {
        "status_code": 201
      },
      "extract": {
        "Order_id_flow004": "id"
      }
    }
  ],
  "object": "Order",
  "method": "PATCH",
  "endpoint": "/services/data/v63.0/sobjects/Order/{Order_id_flow004}",
  "payload": {
    "AccountId": "{seed_Account_0}"
  },
  "expects": {
    "status_code": 204
  },
  "query_after": {
    "object": "Order",
    "record_id": "{Order_id_flow004}",
    "retry": 5,
    "delay_ms": 1000,
    "assertions": [
      {
        "field": "AccountId",
        "operator": "eq",
        "value": "{seed_Account_0}"
      },
      {
        "field": "PLG_BD_Pool__c",
        "operator": "eq",
        "value": false
      }
    ]
  },
  "teardown": {
    "method": "DELETE",
    "endpoint": "/services/data/v63.0/sobjects/Order/{Order_id_flow004}"
  },
  "priority": "P1",
  "bug_ref": "#1106",
  "scene": "flow"
}
