Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

OMNISTUDIO

Integration
Procedure

APEX
OmniStudio
OmniStudio is a low-code development platform
that allows businesses to build custom applications
quickly and easily. It helps to simplify the creation of
complex, industry-specific experiences on
Salesforce.

It is an all-in-one platform that offers a range of tools


and features to help businesses develop and deploy
custom applications without the need for extensive
coding knowledge
Integration Procedure
Integration Procedures in OmniStudio are similar
to Apex classes in terms of their role in application
development but differ in their specific
environments and approaches.

An Integration Procedure features


a click-and-drag UI that is simple
and easy to use, requiring minimal
coding knowledge

Apex is a programmatic approach


that is hard to maintain and requires
a high level of coding knowledge

Can a declarative approach


provide a 100% solution all
the time ?
It may not always provide a complete solution for
all business requirements, particularly when they
are complex or highly customized.

In such cases, a programmatic approach like Apex,


which requires advanced coding skills, can be used
to handle more intricate logic and customizations.
Combining both approaches allows developers to
create robust and interconnected applications

How do you call Apex from an


Integration Procedure?

The Remote Action element calls the specified


Apex class and method or the specified invocable
action. You can also pass in invocation options and
data. The Apex class must implement the Callable
interface.
Scenario: Fetch all records in the SalesOrder
object and update the Priority to 'high' if the
Amount is greater than 120000

Salesorder object info

Sample Records
Step 1 - Fetch the records using Data Raptors

DataRaptors is a mapping tool in Omnistudio facilitating


the seamless handling of Salesforce data enabling users
to read, write & transform data.

In DataRaptor, there are two types of record-fetching


mechanisms: Turbo DataRaptor and Extract DataRaptor.

Note that Turbo DataRaptor is more efficient at runtime


as it extracts data from a single object. Unlike
DataRaptor Extract, Turbo Extract does not include a
formula or output tab but supports a Preview Tab
Preview (It return a JSON Format)
{
"Sales": [
{
"Name": "SO-001",
"Id": "a0KJ3000001lQ7RMAU",
"Amount__c": 120000
},
{
"Name": "SO-002",
"Id": "a0KJ3000001lQ7SMAU",
"Amount__c": 10000000, Human-readable
"Priority__c": "Medium"
},
{
"Name": "SO-004",
Lightweight
"Id": "a0KJ3000001lQ7TMAU",
"Amount__c": 2000000,
"Priority__c": "Low" Easy to use
},
{
"Name": "SO-003",
"Id": "a0KJ3000001lQ7bMAE",
Fast
"Amount__c": 50000
},
{
"Name": "SO-005",
"Id": "a0KJ3000001lQ7gMAE",
"Amount__c": 60000
}
]
}
Step 2 - Create a Integration Procedure

Combination of Type and subType


Integration Procedure name for UI
is a API Name

Drag the Dataraptor turbo action


Step 3 - Drag the Remote action

Apex Class Name Method Name

Note- Apex class must implements interface System.Callable


Step 4 - Passing the input to the apex class

Passing the input as a list of SalesOrder


records

public class IpapexEx implements System.Callable{

Public Object call(String methodName,Map<String,Object> input)


{
system.debug(methodName);
system.debug(input);
return null;
}
}
Step 5- Click Preview and Execute

In Apex, it executes the code line by line. similarly, in


Integration Procedures (IP), actions are executed one by
one. Using debug logs helps to show the results and
execution sequences

A log is created as a result of this execution


Debug Results -
system.debug(methodName); >> testExample

system.debug(input); (Map<String,Object>)

{
input={
SalesorderRecords=(
{Amount__c=120000,Id=a0KJ3000001lQ7RMAU,Name=SO-001},
{Amount__c=10000000,Id=a0KJ3000001lQ7SMAU,Name=SO-002, Priority__c=Medium},
{Amount__c=2000000,Id=a0KJ3000001lQ7TMAU,Name=SO-004, Priority__c=Low},
{Amount__c=50000,Id=a0KJ3000001lQ7bMAE,Name=SO-003},
{Amount__c=60000,Id=a0KJ3000001lQ7gMAE,Name=SO-005}) },
options={}, output={}
}

NOTE: To send information back to the Integration Procedure


from Apex, it needs to be placed in the output field.
Debug Results -
system.debug(dataMap);

{
SalesorderRecords=
({Amount__c=120000,Id=a0KJ3000001lQ7RMAU,Name=SO-001},
{Amount__c=10000000,Id=a0KJ3000001lQ7SMAU,Name=SO002,Priority__c=Medium},
{Amount__c=2000000, Id=a0KJ3000001lQ7TMAU, Name=SO-004, Priority__c=Low},
{Amount__c=50000, Id=a0KJ3000001lQ7bMAE, Name=SO-003},
{Amount__c=60000, Id=a0KJ3000001lQ7gMAE, Name=SO-005})
}

SalesorderRecords is a Additional Inputname

system.debug(inputRecords);

(
{Amount__c=120000,Id=a0KJ3000001lQ7RMAU,Name=SO-001},
{Amount__c=10000000,Id=a0KJ3000001lQ7SMAU,Name=SO-002,Priority__c=Medium},
{Amount__c=2000000,Id=a0KJ3000001lQ7TMAU,Name=SO-004,Priority__c=Low},
{Amount__c=50000,Id=a0KJ3000001lQ7bMAE,Name=SO-003},
{Amount__c=60000, Id=a0KJ3000001lQ7gMAE, Name=SO-005}
)

Note - Each element in the list is a Map<String, Object>


We can now easily loop through the list and check if the
amount exceeds 120000 by accessing the 'Amount__c' value
using the map method .get("Amount__c").
Reference

Note: In the output, I include the recordId and the records with
an amount greater than 120000.
The output format must be a Map<String, Object>
Response Action-

The Response action is a commonly used action. In Apex


methods, if you want to return something, you use the 'return'
keyword. Similarly, in Integration Procedures (IP), we use the
Response action to return something

Here, I return a response from Apex using RemoteAction2


Can u achieve this using declarative
approach ? Definitely Yes

DataRaptor Post Action is used to insert and


upade records

You might also like