SK SKYVVA Documentation

24. SkyvvaSalesforce Sender — Send Opportunity Changes to Reporting Using Salesforce PushTopic Events

1. Overview

Use the SkyvvaSalesforce sender adapter to receive Salesforce Opportunity changes through a continuous PushTopic subscription, transform them with a Groovy script in CPI, and send the result to a Postman reporting mock. An Opportunity represents a potential sale. A real reporting application would maintain a row for its stage, amount and expected close date; this exercise simulates the receiving API instead of supplying that application.

The source is a saved Salesforce Opportunity change, not an event published from Postman. Postman is the destination mock. Its saved response acknowledges the HTTP call but does not store Opportunity rows, compare versions, prevent duplicates or prove reporting acceptance.

This guide supports maintenance of an existing PushTopic integration. Salesforce classifies PushTopic Events as legacy; use CDC or explicit Platform Events when designing a new event integration. PushTopic uses CometD, whose underlying HTTP long-polling differs from the adapter's scheduled Topic - Polling operation. Here Topic - Subscribe stays subscribed, and the CPI Scheduler is unused.

image

Figure 1. Conceptual Salesforce-to-reporting integration, with the reporting API simulated by a Postman mock server.


The diagram shows the intended reporting application. In this tutorial, Postman simulates its API and returns a fixed acknowledgement without storing Opportunity rows.

2. Context Before You Start

Business example

A distributor tracks Elbtal Baustoffbestellung, an Opportunity for building materials. Its initial stage is an open stage allowed by the org's sales process, with Amount 4000. A sales user later changes the stage to Closed Won, keeping Amount at 4000. CPI receives the change and sends the selected Opportunity state to the mock. Use a valid Close Date, such as 2026-12-31.

The request uses the real Salesforce Opportunity Id as its reference and normalized LastModifiedDate as its source version. The illustrative Id/timestamp in the examples are fixtures; do not enter them as a real source record or expect them in every live call. The mock's acknowledgement has no record Id or version, so its saved response does not need to be rewritten after each save.

The query has no open-stage filter, so Closed Won does not exclude the Opportunity from notifications. It also selects LastModifiedDate; changes to that field can cause notifications even when the selected business values are unchanged. Amount must be a number or explicit null. A missing Amount field is rejected and does not mean clear the value. The example assumes one agreed currency.

Prerequisites

No real reporting API, ReportingApiUser credential, database or target persistence is required for this exercise. The receiving mock must be provisioned before deployment; importing a collection alone does not create a hosted server.

Initial Latest receives new events, not an existing Opportunity baseline. Create the dedicated test record after the subscriber connects. PushTopic retention is 24 hours; expired events cannot be recovered by replay. The adapter's client-managed replay position advances before later CPI steps finish, so reconnect alone does not guarantee retry of a failed mock call. Keep failed-run evidence and plan durable recovery/reconciliation for production. No SKYVVA Integration/Interface or generated outbound trigger is used here.

3. Inspect the PushTopic contract

Have the Salesforce administrator check whether OpportunityPipeline exists before connecting CPI. If it does not exist, create the PushTopic in Salesforce using the settings below, then verify the saved record. If it already exists, verify and reuse it instead of creating another topic. Its channel is /topic/OpportunityPipeline and its selected fields define the data.sobject body delivered to the sender.

SettingValueDescription
Name / channelOpportunityPipeline / /topic/OpportunityPipelineDedicated topic used by this exercise
QuerySELECT Id, Name, StageName, Amount, CloseDate, LastModifiedDate FROM OpportunityFull selected state; no IsClosed filter
ApiVersion61.0, or a supported versionConfirm with the intended org and deployed adapter
IsActivetrueConfirm that notifications are enabled
NotifyForFieldsSelectEvaluate changes to selected fields, including LastModifiedDate
Create / Update / UndeletetrueSupported event types for the transformation
DeletefalseDeletions require separate reconciliation

In Developer Console → Query Editor, run this query first:

SELECT Id, Name, Query, ApiVersion, IsActive, NotifyForFields,
       NotifyForOperationCreate, NotifyForOperationUpdate,
       NotifyForOperationDelete, NotifyForOperationUndelete
FROM PushTopic WHERE Name = 'OpportunityPipeline'

If it returns a record, compare its settings with the table above and reuse it. If it returns no records, create the topic with the Apex below. Run SOQL in Query Editor and Apex in Execute Anonymous.

Create the topic only if it does not exist. As an authorized Salesforce administrator, open Developer Console → Debug → Open Execute Anonymous Window, paste the following Apex and click Execute. Run it once; if the topic already exists, skip this code and verify its settings instead.

PushTopic topic = new PushTopic();
topic.Name = 'OpportunityPipeline';
topic.Query = 'SELECT Id, Name, StageName, Amount, CloseDate, LastModifiedDate FROM Opportunity';
topic.ApiVersion = 61.0;
topic.NotifyForFields = 'Select';
topic.NotifyForOperationCreate = true;
topic.NotifyForOperationUpdate = true;
topic.NotifyForOperationDelete = false;
topic.NotifyForOperationUndelete = true;
insert topic;

Query the saved PushTopic again and confirm the settings above, including IsActive = true, before deploying the iFlow. This code creates the topic definition. Saving an Opportunity later triggers the change notification.

image

Figure 2. Saved Opportunity pipeline PushTopic contract.


For an existing topic, deliberately review any query/flag change with its owner. Do not overwrite another feed or insert a duplicate. The adapter receives from this pre-created channel; this guide does not depend on its hidden/commented-out topic auto-creation fields. No custom Platform Event definition or ManagedEventSubscription is required.

Deletion notifications are deliberately excluded. A later reporting reconciliation must remove or deactivate deleted records according to agreed retention rules. Changing the query can also exclude records without sending a deletion; absence of an event is not proof of deletion.

4. Configure the continuous sender

The verified topic identifies the changes to receive. Build Opportunity Pipeline to Reporting in your CPI test package. The process transforms each event, sends it to a Postman reporting mock and checks its fixed acknowledgement before ending.

Sender (Salesforce) -- SkyvvaSalesforce --> Start (Receive Opportunity Change)
  → Groovy Script (Build Pipeline Record)
  → Request Reply (Deliver Pipeline Record)
  → Groovy Script (Check Mock Response)
  → End (Complete Pipeline Update)

HTTP receiver branch:
Request Reply (Deliver Pipeline Record) -- HTTP --> Receiver (Reporting Mock)

Only the text in parentheses is entered in General → Name; the preceding text identifies the component to add. The response returns to Request Reply, and the main process continues to Check Mock Response.

image

Figure 3a. Continuous Opportunity pipeline flow.


Connection fieldValue
General: Name / DirectionReceiveOpportunityPipeline / Sender
Authentication TypeOAuth2
OAuth2 FlowClient Credential
Login UrlActual Salesforce My Domain base URL
Client Credentialskyvva-client-credentials

This custom adapter reads skyvva-client-credentials from CPI User Credentials, using User for Client ID and Password for Client Secret. Do not append /services/oauth2/token to Login Url. Use the intended run-as user's permissions and keep credential values out of screenshots.

image

Figure 3b. Salesforce sender connection.


Processing fieldValue
Processing Mode / Event TypeEvent Processing / PushTopic Events
OperationTopic - Subscribe
Channel Name/topic/OpportunityPipeline
Replay Id ApproachEvents from latest position (Latest), for controlled initial setup
Subscription Behaviour On ResetReplay from last processed message
Replay Preset for Invalid Replay IDEarliest
Subscription MechanismSubscribe on one runtime node
Message Expiration (in ms)300000; adapter duplicate-memory period, not event retention
Max Buffer Size (in bytes)10485760
Process Errors as an EventEnabled; builder rejects diagnostic events
Payload Format / Pretty PrintApplication/JSON / enabled
Logging option / Salesforce Api VersionDefault / 61.0 or a supported deployed-adapter version
SchedulerLeave unchanged; unused for Topic - Subscribe

Platform Event/CDC managed-subscription and request-batch controls do not apply. Custom Replay Id is unused with Latest. Leave Max Network Delay at the displayed default; the current code does not use that field to control the live subscription wait. Other unrelated settings remain at their applicable defaults.

Replay from last processed message is a UI label, not a target-success checkpoint. With saved-position reset behavior, an existing stored position can take precedence over initial Latest. Do not clear that position merely to run a test. Earliest recovery can repeat retained events but cannot recover expired events. One-runtime-node selection does not establish exactly-once delivery or guaranteed automatic standby takeover.

image

Figure 4. Continuous client-managed PushTopic subscription.

5. Transform Opportunity state

The received PushTopic envelope contains the selected Opportunity fields under data.sobject, rather than the Platform Event data.payload structure used in Tutorial 26. The Groovy Script (Build Pipeline Record) validates that envelope and produces one reporting item for the Opportunity.

At Build Pipeline Record → Message before Step → Payload, inspect the incoming Opportunity fields before transformation.

image

Figure 5a. Received Opportunity change.


Source valueTarget valueDescription
data.sobject.Iditems[0].referenceStable Opportunity key
data.sobject.LastModifiedDateitems[0].sourceVersionNormalized UTC timestamp
data.sobject.Nameitems[0].fields.nameOpportunity name
data.sobject.StageNameitems[0].fields.stageCurrent stage, including Closed Won
data.sobject.Amountitems[0].fields.amountNumber or explicit null; never formatted currency text
data.sobject.CloseDateitems[0].fields.closeDateDate or offset timestamp normalized to YYYY-MM-DD without timezone shifting
created / updated / undeleteditems[0].operation = UPSERTIntended real-service action; the mock does not store a row

The builder rejects unsupported channels/event types and malformed roots. It normalizes timestamps such as +0000 or Z to UTC ISO text. A real reporting service would compare parsed timestamps; the mock does not compare versions. UPSERT means creating a missing row or updating an existing row by its key; here it is only a field in the request, not a storage operation performed by Postman. The script also sets Content-Type, Accept and an Idempotency-Key derived from the prepared request. A header does not implement target-side deduplication.

Pretty Print formats the incoming Salesforce event. The Groovy builder produces compact JSON for the reporting request, so its output may still appear on one line.

Close Date accepts an ISO date such as 2026-12-31 or an offset timestamp such as 2026-11-04T00:00:00.000Z. The builder sends date-only text (2026-11-04 in that example), preserving the calendar date represented in the source value. This works for any valid calendar date, including leap days; blank values, impossible dates and formats such as 31/12/2026 are rejected. Compare the actual saved Close Date after changing the Opportunity stage; closing an Opportunity as Won can replace a future Close Date with the current date.

Request produced by the Groovy script for the illustrative Closed Won event:

{
  "items": [
    {
      "reference": "006000000000001AAA",
      "sourceVersion": "2026-10-10T01:10:00Z",
      "operation": "UPSERT",
      "fields": {
        "name": "Elbtal Baustoffbestellung",
        "stage": "Closed Won",
        "amount": 4000,
        "closeDate": "2026-12-31"
      }
    }
  ]
}

No graphical Message Mapping or XSD is required. The identifier and timestamps in these examples are fixtures; the live test must use the real Opportunity Id and actual source version received from Salesforce.


image

Figure 5b. Reporting request produced by the Groovy script.

6. Deliver the request to the Postman mock

The HTTP receiver connection sends the prepared JSON to the Postman mock's POST /api/opportunity-upserts endpoint. Configure the mock to select its one saved response by method/path, with body and header matching disabled, so real Opportunity identifiers, timestamps and Idempotency-Key values may vary.

The fixed acknowledgement is:

{
  "status": "RECEIVED",
  "mock": true
}

The Groovy Script (Check Mock Response) requires HTTP 200, status: RECEIVED and mock: true. It does not claim a saved reporting row or compare returned record versions. The full request must therefore be checked separately in the mock server call log against the actual source event and CPI transformation.

Select Check Mock Response → Message before Step → Payload to see the acknowledgement returned by Postman.

image

Figure 6a. Postman mock acknowledgement received in CPI.


HTTP receiver fieldValue
General: NameDeliverPipelineRecord
Connection: Addresshttps://<your-mock-id>.mock.pstmn.io/api/opportunity-upserts; paste the generated URL
Proxy TypeInternet
Method / QueryPOST / blank
AuthenticationNone for the public Postman mock
Credential NameNot used with None
Timeout (in ms)60000
Request Headerstraceparent|Accept|Idempotency-Key
Response HeadersLeave default
Throw Exception on FailureEnabled
Attach Error Details on FailureEnabled
Retry on Exception / Retry on Error ResponseDisabled for the first test

Enter traceparent|Accept|Idempotency-Key as one value in Request Headers, using literal pipes between the header names. traceparent is forwarded when present; this setting does not create it. The builder sets Content-Type and Accept to application/json; verify them and the actual body in the mock log. The Idempotency-Key remains part of the request, but the mock does not use it for deduplication. No ReportingApiUser Basic-auth credentials are needed. A private mock instead requires an x-api-key header supplied securely and included in forwarded Request Headers.

A fixed HTTP 200 can be returned even for incorrect business values when body matching is disabled. A completed flow alone is insufficient evidence of a correct transformation; compare the actual Id, version, name, stage, amount and close date across the source, request and mock log. This mock does not establish reporting persistence, duplicate prevention, stale-version rejection or recovery guarantees.

7. Test an Opportunity change through the mock

Prepare the topic, builder, mock checker and Postman mock before deploying. Confirm that Topic - Subscribe is connected before creating or editing the dedicated test Opportunity. Leave the Scheduler unchanged.

  1. In Salesforce → Opportunities → New, create Elbtal Baustoffbestellung with an allowed open stage, Amount 4000 and a valid Close Date such as 2026-12-31. Supply the Account and any other org-required fields, then save. Record its actual Id. The create event may produce an initial mock call; distinguish that from the later update. If reusing an existing record, subscription startup alone does not send its state.
  2. Enable temporary CPI Trace. Open the same saved Opportunity → Edit, change Stage to Closed Won (or the agreed equivalent permitted by the sales process) and keep Amount at 4000, then save once. Reopen the saved record and use its actual Close Date in the comparison; Salesforce may change a future date when closing as Won. That save produces the PushTopic notification. If the record is already Closed Won with Amount 4000, make another allowed field change for a repeat test and compare the actual new values; saving unchanged values is not a reliable way to demonstrate a new notification. Do not POST a Platform Event or the sender-envelope fixture from Postman.
  3. In CPI → Monitor → Monitor Message Processing, locate the corresponding execution. At Build Pipeline Record input, verify the actual Id, data.event.type updated and selected values. Select Deliver Pipeline Record → Message before Step → Payload to verify the prepared items entry and normalized sourceVersion. Select Check Mock Response → Message before Step → Payload to inspect the fixed acknowledgement, and check the HTTP response-code header is 200.
  4. In the Postman mock call log, find the matching CPI request by path, time, real Id and version. Compare all transformed business fields and Idempotency-Key. Capture the evidence, then restore normal logging. No saved reporting row is expected.
image

Figure 6b. Reporting mock call log with the transformed Opportunity request.


The fixed response does not change between Opportunity versions. Its absence of Id/version is intentional: it tests transport and the acknowledgement contract. Correct mapping is established by the actual source/request/log comparison, not by receiving HTTP 200 alone.

If Salesforce omits Amount rather than returning explicit null, stop and inspect the actual payload; the builder rejects a missing Amount instead of converting it to null. Do not call a successful mock response proof that a reporting amount was cleared.

A failed HTTP call can occur after the adapter has saved the client-managed replay position. Keep failed-run evidence; reconnecting alone does not guarantee the same event will be retried. For production, provision durable error handling/resend and reconcile actual reporting state. A current-state source read cannot reconstruct every historical stage transition.

8. Summary

The exercise continuously receives a Salesforce Opportunity change, transforms its selected state in CPI and sends it to a Postman reporting mock. The mock returns a fixed acknowledgement checked by a dedicated Groovy script. This demonstrates event delivery, transformation and HTTP response handling; a reporting database, durable acceptance, duplicate prevention and version ordering are separate production capabilities.

Configuration Summary

ComponentConfiguration
SenderPushTopic Events → Topic - Subscribe; Scheduler unused
Channel / transport/topic/OpportunityPipeline / CometD
Request identityReal Opportunity Id / normalized LastModifiedDate
TransformationGroovy script in CPI; data.sobject to one items entry
DeliveryPostman mock POST /api/opportunity-upserts; Authentication None for public access
Response checkHTTP 200, status RECEIVED, mock true
Not establishedReporting persistence, duplicate prevention, stale-version rejection and durable recovery
Replay boundary24-hour PushTopic retention; client checkpoint precedes later step success

Open this article in the interactive viewer →