Get Compound Fields in Change Events

Compound fields, such as lead or contact Name, Address, and Geolocation fields, are represented as nested field structures in the event message. In record updates, the changedFields header field lists each updated component field using this format: CompoundField.ComponentField. The updated component field is included in the event message in a nested field structure.

The name of the component field can differ from the field name in the corresponding Salesforce object. For example, in a change event, the Street nested component field of BillingAddress is BillingStreet in the Account object. To find out the field names and structure in a change event, get the event schema. For more information about the event schema, see Change Event Message Structure. For more information about Salesforce objects, see Standard Objects in the Object Reference for Salesforce and Lightning Platform.

Note

Compound Field in a New Record

Example

This example shows a change event received after an account is created with a BillingAddress compound field. The BillingAddress field contains its component fields as nested fields.

{
  "ChangeEventHeader": {
    "entityName": "Account",
    "recordIds": [
      "0015f00002JUXA8AAP"
    ],
    "changeType": "CREATE",
    "changeOrigin": "com/salesforce/api/soap/60.0;client=SfdcInternalAPI/",
    "transactionKey": "00006bec-ce66-0611-9018-30a98446c9f2",
    "sequenceNumber": 1,
    "commitTimestamp": 1714156685000,
    "commitNumber": 1100670838951,
    "commitUser": "0055f000005mc66AAA",
    "nulledFields": [],
    "diffFields": [],
    "changedFields": []
  },
  "Name": "Acme",
  "Type": null,
  "ParentId": null,
  "BillingAddress": {
    "Street": "415 Mission Street",
    "City": "San Francisco",
    "State": "CA",
    "PostalCode": "94105",
    "Country": "United States",
    "Latitude": null,
    "Longitude": null,
    "GeocodeAccuracy": null
  },
  "ShippingAddress": null,
  "Phone": null,
  "Fax": null,
  "AccountNumber": null,
  "Website": null,
  "Sic": null,
  "Industry": null,
  "AnnualRevenue": null,
  "NumberOfEmployees": null,
  "Ownership": null,
  "TickerSymbol": null,
  "Description": null,
  "Rating": null,
  "Site": null,
  "OwnerId": "0055f000005mc66AAA",
  "CreatedDate": 1714156685000,
  "CreatedById": "0055f000005mc66AAA",
  "LastModifiedDate": 1714156685000,
  "LastModifiedById": "0055f000005mc66AAA",
  "Jigsaw": null,
  "JigsawCompanyId": null,
  "CleanStatus": "Pending",
  "AccountSource": null,
  "DunsNumber": null,
  "Tradestyle": null,
  "NaicsCode": null,
  "NaicsDesc": null,
  "YearStarted": null,
  "SicDesc": null,
  "DandbCompanyId": null,
  "OperatingHoursId": null,
  "CustomerPriority__c": null,
  "SLA__c": null,
  "Active__c": null,
  "NumberofLocations__c": null,
  "UpsellOpportunity__c": null,
  "SLASerialNumber__c": null,
  "SLAExpirationDate__c": null
}

Compound Field in an Updated Record

Example

This example shows a change event received after updating the Street component field of BillingAddress. The Street field is nested under BillingAddress.

{
  "ChangeEventHeader": {
    "entityName": "Account",
    "recordIds": [
      "0015f00002JUXA8AAP"
    ],
    "changeType": "UPDATE",
    "changeOrigin": "com/salesforce/api/soap/60.0;client=SfdcInternalAPI/",
    "transactionKey": "00006bf0-edfd-6e54-a3f9-e8cefdb2c2b7",
    "sequenceNumber": 1,
    "commitTimestamp": 1714156703000,
    "commitNumber": 1100671026205,
    "commitUser": "0055f000005mc66AAA",
    "nulledFields": [],
    "diffFields": [],
    "changedFields": [
      "0x400000",
      "4-0x01"
    ]
  },
  "Name": null,
  "Type": null,
  "ParentId": null,
  "BillingAddress": {
    "Street": "415 Mission Street Suite B",
    "City": null,
    "State": null,
    "PostalCode": null,
    "Country": null,
    "Latitude": null,
    "Longitude": null,
    "GeocodeAccuracy": null
  },
  "ShippingAddress": null,
  "Phone": null,
  "Fax": null,
  "AccountNumber": null,
  "Website": null,
  "Sic": null,
  "Industry": null,
  "AnnualRevenue": null,
  "NumberOfEmployees": null,
  "Ownership": null,
  "TickerSymbol": null,
  "Description": null,
  "Rating": null,
  "Site": null,
  "OwnerId": null,
  "CreatedDate": null,
  "CreatedById": null,
  "LastModifiedDate": 1714156703000,
  "LastModifiedById": null,
  "Jigsaw": null,
  "JigsawCompanyId": null,
  "CleanStatus": null,
  "AccountSource": null,
  "DunsNumber": null,
  "Tradestyle": null,
  "NaicsCode": null,
  "NaicsDesc": null,
  "YearStarted": null,
  "SicDesc": null,
  "DandbCompanyId": null,
  "OperatingHoursId": null,
  "CustomerPriority__c": null,
  "SLA__c": null,
  "Active__c": null,
  "NumberofLocations__c": null,
  "UpsellOpportunity__c": null,
  "SLASerialNumber__c": null,
  "SLAExpirationDate__c": null
}

After decoding the changedFields header field in a Pub/Sub API client, the updated Street field is listed as BillingAddress.Street.

2024-04-26 11:38:24,375 [grpc-default-executor-0] java.lang.Class - ============================
2024-04-26 11:38:24,375 [grpc-default-executor-0] java.lang.Class -        Changed Fields       
2024-04-26 11:38:24,375 [grpc-default-executor-0] java.lang.Class - ============================
2024-04-26 11:38:24,375 [grpc-default-executor-0] java.lang.Class - LastModifiedDate
2024-04-26 11:38:24,375 [grpc-default-executor-0] java.lang.Class - BillingAddress.Street
2024-04-26 11:38:24,375 [grpc-default-executor-0] java.lang.Class - ============================