To do some more business logic after the processing of an interface. We will add a new operation type name ‘Autolaunched flow’ for interface. This operation type is using for customers who want to add more their business logic by using Salesforce Flow.
What is Autolaunched 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. Currently, we support different interface operation for the inbound interface like following:
- upsert
- update
- insert
- delete
- Query
- Pull Query
- upsert Auto External Id
- update Auto External Id
- Delete Auto External Id
- Autolaunched Flow
Steps to use the operation type Autolaunched Flow : #
Step1: Create a flow with type autolaunched
Go to Setup and search for flow in Quick find/Search
- Create new flow with name customerflow
Step2: Create an apex class for invoking from flow(customerflow):
This apex class is used to update status and comment message after processing flow finished.
[aux_code language=”javascript” theme=”tomorrow” title=”” extra_classes=””]
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;
}
}
[/aux_code]
Step 3: 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: 5. We can check on message board:
When we push uploaded data, we can see the result on message monitoring page.