SK SKYVVA Documentation

1. How to subscribe Salesforce Platform Event created by SKYVVA inbound interface?

Learning Objective: After completing this unit, you’ll be able to:

Introduction

To subscribe platform event we can use the apex trigger. We use generic method to execute the interface either it is an inbound or outbound interface. Execution of interface using apex trigger is is a Salesforce solution. But with Skyvva we can enrich the event data with mapping and process the data after we have mapped the event/message. Here It is the same way as we process an incoming message through the skyvva processing pipeline e.g. workflow, mapping, processing.

Platform event

Platform events enable developers to deliver secure, scalable, and customizable event notifications within the Salesforce platform or from external sources. Platform events are based on a publish-subscribe architecture.

How Platform event work with inbound processing?

How to create the platform event SKYVVA feature?

We can create a platform event without programming with SKYVVA feature. Creating an event can be done using the inbound or outbound interface. With the inbound interface, we get data from the outside and with this data, we can create an event either into the Salesforce bus. Follow the given steps to create platform event with SKYVVA: Step1: Create platform Event:

Step2: Create custom Fields

Repeat same process to create Name field. Step3: Create Integration

Step4: Create interface.  We can execute inbound interface with our new API i,e Event Interface.

Step5: Do mapping

Step6: Upload data manually.

Step7: Search result on message Monitoring:

How to consume the platform event created through Skyvva?

We can to consume the event by using :

External Client using CometD protocol

User can write themselves a cometD. They can use any supported programming language from Salesforce.

Apex Trigger:

trigger is an Apex script that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted. Triggers enable to perform custom actions before or after changes to Salesforce records. How to create Trigger:

Use the given Code to apex trigger: [aux_code language="javascript" theme="tomorrow" title="" extra_classes=""] trigger trgPlatformAccountEvent on Platform_Event_Account__e (after insert) { List lst = new List(); for(Platform_Event_Account__e evt: Trigger.New) { Account acc = new Account(); acc.Name = evt.Name__c + 'evt' ; acc.AccountNumber = evt.AccountNumber__c + 'evt' ; lst.add(acc); } insert lst; }[/aux_code]

Make sure Apex Identifier should be correct. For example 'evt'. if you copy code from browser then it will take char in HTML . when the apex trigger is used to consume the platform event we can check created record and its data. All the custom fields which we added in platform event are shows with 'evt'. For example AccountNumber+evt, name+evt. Follow the steps to show How to use the apex trigger to consume the platform event? Step1: Go to created integration-> Open your Interface -> go to manual Load -> Uplaod data

Go to message board -> Search for result;

step 3: Search created record in developer console:

You can see the data with evt.

Process builder:

Process Builder is a Salesforce’s point-and-click tool that lets you easily automate if/then business processes and see a graphical representation of your process as you build. Every process consists of a trigger, at least one criteria node, and at least one action. You can configure immediate actions or schedule actions to be executed at a specific time. Here we are using process builder to consume platform event. Follow the given steps to show how process builder to consume platform event. Here we are using same Integration and interface. we have to deactivate apex trigger. Step 1: Create process using process builder.

  1. Select Platform Event
  1. Choose object as Account
  1. Add Matching condition where I put this condition on Account name field.;-
  1. Name the Criteria
  2. Choose No Criteria option
  3. click on Save button .
  1. Select the Action Type: Create Record
  2. Give the Action Name: Account Creation
  3. Select Record type: Account
    • Set Field Values as per data and platform event reference

To be able to execute process builder, just click on Activate button.

step2: manually Load data

Step 3: Monitor the result on message board

As this record are created by process builder consuming platform event we can't see details of created record. we can't get Related to" link here. we can check data in dev console. Step 4: Search created record in developer console:

Note: The process runs asynchronously under the Automated Process entity. As a result, there can be a delay between when an event message is published and when the process evaluates the event message

Flow

Open this article in the interactive viewer →