{
  "id": "LC-OCR-ROLE-ACTION-DEFAULT",
  "name": "Admin ActionFieldDefault supplies OCR Role during Lead Convert subflow",
  "description": "Design regression guard: Std_SyncOpportunityContactRole must stay tenant-neutral and omit Role, while _System_ActionFieldDefault can provide an org-owned OpportunityContactRole.Role value that flows through the parent convertLead action context into the subflow-created OCR row.",
  "object": "LeadConvert",
  "method": "POST",
  "endpoint": "/services/data/v63.0/actions/standard/convertLead",
  "setup": [
    {
      "type": "sql",
      "sql": "INSERT INTO `_System_ActionFieldDefault` (Id, StandardActionId, TargetObject, FieldAPIName, ValueFormula, Priority, IsCustomized, IsActive, IsDeleted, CreatedDate, LastModifiedDate) VALUES ('afd_convertlead_ocr_role_e2e', 'sa_convertlead', 'OpportunityContactRole', 'Role', '\\'Admin Picklist Value\\'', 10, 1, 1, 0, NOW(), NOW()) ON DUPLICATE KEY UPDATE ValueFormula=VALUES(ValueFormula), Priority=VALUES(Priority), IsCustomized=1, IsActive=1, IsDeleted=0, LastModifiedDate=NOW()"
    }
  ],
  "payload": {
    "inputs": [
      {
        "leadId": "{seed_Lead_0}",
        "convertedStatus": "Converted",
        "opportunityName": "OCR Role Default Opportunity"
      }
    ]
  },
  "expects": {
    "status_code": 200
  },
  "extract": {
    "opportunity_id": "0.outputValues.opportunityId",
    "contact_id": "0.outputValues.contactId"
  },
  "query_after": {
    "object": "OpportunityContactRole",
    "id_field": "OpportunityId",
    "record_id": "{opportunity_id}",
    "select_fields": ["ContactId", "Role", "IsPrimary"],
    "assertions": [
      {"field": "ContactId", "operator": "eq", "value": "{contact_id}"},
      {"field": "Role", "operator": "eq", "value": "Admin Picklist Value"},
      {"field": "IsPrimary", "operator": "eq", "value": true}
    ]
  },
  "teardown": [
    {
      "type": "sql",
      "sql": "UPDATE `_System_ActionFieldDefault` SET IsActive=0, IsDeleted=1 WHERE Id = 'afd_convertlead_ocr_role_e2e'"
    }
  ],
  "priority": "P0",
  "scene": "lead_convert"
}
