Tutorial

  1. Home
  2. Docs
  3. Tutorial
  4. 31. Different way how to invoke outbound interface
  5. 31.1 How to push data from Salesforce by using a button, trigger, the process build process?

31.1 How to push data from Salesforce by using a button, trigger, the process build process?

Learning Objective:

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

  • Describe which are the invoke outbound interface methods.
  • Comfortably use all the methods to push data from Salesforce by using a button, trigger, the process build process.

Introduction

To show the different technology which can be use to push data to the external client by using Skyvva. For example, different possibility  like: Using Trigger, Process Builder process, Flow, Apex class to send data out. The callout methods are using to send data from salesforce to external system (SFDC to SAP/SAP-PI) through interface outbound. The Service only sends one record/children per request to SAP. To invoke callout from apex trigger the method invokeCallout(interfaceId, ids, ‘AUTO’) is recommended.

Why we use button, trigger, the process build process to push data from salesforce?

  • Process Builder: Here customer can use the Process Builder to catch the changes. When the change of a record is recognize an apex class is called and in this apex class we can invoke our API invokeCalloutXX().
  • Button : when user push a button the change data should sent
  • Trigger: When a record is changed the change data should sent.
  • Flow:
  • Apex Class:

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. To keep things simple, this unit focuses on the most common process type: Record Change, which mean the process, will start when the records are created or edited.

The configuration

To be able to execute callout, you have enter interface page detail and scroll down to Runtime Configuration- Outbound section then check flag “Use Skyvva Outbound Scheduler”.

Note

– If you want to execute callout, the flag could be blank.

– If you want to create CP Record, the flag is required.

  • The interface could be set creating change pointer by process builder or trigger. You have to select SKYVVA API. This is the pre-requisite to create process builder.

This part is mainly explain the process of creating the process builder in order to create change pointer records. To build process builder, you can follow the steps below:

  • From Setup, enter Process Builder in the Quick Find Box, click Process Builder. When you are on process builder page, click on New button.

  • Fill in the name of the process

  • Add the Object and Specify when to start the Process.

  • Add the Criteria to define it for Action Group:
    1. Name the Criteria
    2. Choose Formula evaluate to true
    3. Build Formula by insert the Function and Field then click Save .

  • Add the actions to execute when the criteria are met by:
    1. Select the Action Type: Apex
    2. Select the Action Name: Create CP Record
    3. Select Apex Class: SKYVVA Callout/Create CP. When you section it, some of dropdown list will appear for you to choose. Then click Add Row to add 2 more.

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

To monitor change pointer records: You can check the change pointer records in CDC Control Board.

 

Trigger

When a record is changed the change data should sent. Whenever a record e.g. an account in Salesforce is changed this change are sent immediately to the client. This is the opposite way to the batch/async. variant.

Follow the given steps:

  • Select Trigger Type “APEX TRIGGER”
  • Tick Trigger Event (can tick more than one)
  •  Select your Integration Name
  •   Select your Interface Name (show only outbound interface)
  •  Select SObject Name
  •  Select Trigger Mode : None, Auto, Future, Batch
  • Click button “Generate Script”
  • Now you will see the script apex trigger in the box and can copy to use it
  • In the script, change to your own name <trigger name> to your own name

 Button

  • Select Trigger Type “BUTTON”
  • Select your Integration Name
  • Select your Interface Name (show only outbound interface)
  • Select SObject Name
  • Select Trigger Mode: Sync,Future,Batch
  • Click button “Generate Script”
  • Now you will see the script trigger button in the box and can copy to use it.

Flow

This is the feature to provide the post-processing logic using Salesforce Flow and Process Builder. Therefore we pass to the Flow/Process the sObject Id which has been created, updated or deleted by the interface operation.

How to create flow?

Follow the gien step to create salesforce flow:

Step1:  Create Apex Class

global with sharing class TestInvokeWorkflow {
@InvocableMethod
global static void updateMessage(List<ClassProperties> myDto){
try{
List<Account> lstAcc = new List<Account>();
List<skyvvasolutions__IMessage__c> lstMsg = new
List<skyvvasolutions__IMessage__c>();
List<skyvvasolutions__IMessage__c> lstUpdate= new
List<skyvvasolutions__IMessage__c>();
for(ClassProperties dto: myDto){
lstAcc.addAll(dto.myListAcc);
lstMsg.addAll(dto.myListMSG);
}
for(Integer i=0;i< lstAcc.size(); i++){
if(lstAcc[i].Id !=null){
lstMsg[i].skyvvasolutions__Status__c = ‚Completed‘;
lstMsg[i].skyvvasolutions__Comment__c = ‚Success from flow‘;
lstUpdate.add(lstMsg[i]);
}else{
lstMsg[i].skyvvasolutions__Status__c = ‚Failed‘;
lstMsg[i].skyvvasolutions__Comment__c = ‚Failed from flow‘;
lstUpdate.add(lstMsg[i]);
}
}
update lstUpdate;
}catch(Exception ex){}
}
global class ClassProperties{
@InvocableVariable(Required = true)
global List<Account> myListAcc;
@InvocableVariable(Required = true)
global List<skyvvasolutions__IMessage__c> myListMSG;
}
}

Step2:  Create a flow with type autolaunched

Go to Setup and search for flow in Quick find/Search

  • Create new flow with name  customerflow

How to use flow?

Create new integration and interface
We create a new interface with:

– Operation type : Autolaunched Flow
– Source/Target Name: Account
– Custom Flow: customerflow
– Do mapping (Account)

 

Go to interface Detail:

Scroll down the page to mapping section>

Step4: Push data by Manual Load:
We choose Account as a sample data.

Push the selected data and click on message board button.

 

Step5: We can check on message board:

When we push uploaded data, we can see the result on message monitoring page.

 

Apex Class

In Apex, user can define top-level classes (also called outer classes) as well as inner classes, that is, a class defined within another class. You can only have inner classes one level deep.

public class myOuterClass {
// Additional myOuterClass code here
class myInnerClass {
// myInnerClass code here
}
}

follow the given steps to use apex class:

Step 1: Create Integration

Step 2: Create interface

– Select operation Type: Apex class from drop down
–  Save

Step 3: Create this class is used for Apex Custom class on Interface and Click on wrench icon and click on Setup.

  • Write Apex Class in Quick find box
  • Click on Apex Classes under Custom Code drop down

 

  • Write this class is used for Apex Custom class in interface
  • Quick save
  • Make sure your code has been saved successfully

  • Create this class is used for testing operation type Apex

  • Go to Interface Detail Page
  • Select TestCustomApexClass
  • Save

  • Scroll down to Mapping Section
  • Select Ext ID
  • Save

  • Go to Integration Detail Page
  • Select Manual Load

  • Select Integration Name& Interface
  • Select Data Type
  • Select CSV Separator
  • Choose file & upload

  • Select all records
  • Press Push button

  • Go to Message Board
  • Select your Integration
  • Select your Interface
  • Press Search Button

  • Scroll down to Message section
  • See status Green Flag which means user inbound apex class operation successfully
    done
  • All records are integrated with Salesforce Org.

 

 

 

 

 

Was this article helpful to you? Yes No

How can we help?