Omnistudio : Invoke Omnistudio IntegrationProcedure Calls from LWC

Nagendra SinghNagendra Singh
2 min read

Introduction

Salesforce's Omnistudio offers amazing tools for creating guided workflows and dynamic business processes. One of the coolest features in Omnistudio is the Integration Procedure, which lets you call external systems or handle data within Salesforce. In this blog, we'll dive into how to make Omnistudio Integration Procedure calls right from a Lightning Web Component (LWC).

Prerequisites

Before we jump into the implementation, make sure you have the following:

  • A basic understanding of Lightning Web Components (LWC)

  • Familiarity with Salesforce Omnistudio and its Integration Procedures

  • A Salesforce org with Omnistudio enabled

Setting Up the LWC

Let's start by creating a simple LWC that will call an Integration Procedure. Here’s the code for the component:

<template>
    <lightning-button class="slds-p-around_medium" onclick={callAPI} variant="neutral" label="Call To API"></lightning-button>
</template>
import {LightningElement} from 'lwc';
import {OmniscriptActionCommonUtil} from 'omnistudio/omniscriptActionUtils';
import {OmniscriptBaseMixin} from 'omnistudio/omniscriptBaseMixin';

export default class DemoCallIpFromLwc extends OmniscriptBaseMixin(LightningElement) {

    _actionUtilClass;

    connectedCallback() {
        this._actionUtilClass = new OmniscriptActionCommonUtil();
    }

    callAPI(event) {
        event.preventDefault();
        this.isPageLoading = true;
        const options = {
            chainable: false,
            useFuture: false,
        };
        const params = {
            input: JSON.stringify({}),
            sClassName: 'omnistudio.IntegrationProcedureService',
            sMethodName: 'Util_FetchAPIData', //this will need to match type_subtype from IP
            options: JSON.stringify(options),
        };

        this._actionUtilClass
            .executeAction(params, null, this, null, null)
            .then(resp => {
                this.isPageLoading = false;
                console.log('resp => ' + JSON.stringify(resp))
            })
            .catch(error => {
                this.isPageLoading = false;
                console.error('error => ' + JSON.stringify(error));
            });
    }
}

The IP which I created here just does a callout, but this can be any logic.

This way, you don't have to write any Apex class for doing server-side logic from LWC.

Testing the LWC

Deploy this component and add it to a Lightning page. Make sure the Integration Procedure exists in your Salesforce org and is set up correctly. When you trigger the callAPI method (for example, by clicking a button), the Integration Procedure will run, and you'll see the results in the browser console.

Conclusion

This blog gave you a step-by-step guide on how to call an Omnistudio Integration Procedure call in LWC. With this method, you can easily connect to external systems and handle data within Salesforce, using the strengths of both Omnistudio and Lightning Web Components.

0
Subscribe to my newsletter

Read articles from Nagendra Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nagendra Singh
Nagendra Singh

Allow me to introduce myself, the Salesforce Technical Architect who's got more game than a seasoned poker player! With a decade of experience under my belt, I've been designing tailor-made solutions that drive business growth like a rocket launching into space. πŸš€ When it comes to programming languages like JavaScript and Python, I wield them like a skilled chef with a set of knives, slicing and dicing my way to seamless integrations and robust applications. 🍽️ As a fervent advocate for automation, I've whipped up efficient DevOps pipelines with Jenkins, and even crafted a deployment app using AngularJS that's as sleek as a luxury sports car. 🏎️ Not one to rest on my laurels, I keep my finger on the pulse of industry trends, share my wisdom on technical blogs, and actively participate in the Salesforce Stackexchange community. In fact, this year I've climbed my way to the top 3% of the rankings! πŸ§—β€β™‚οΈ So, here's to me – your humor-loving, ultra-professional Salesforce Technical Architect! πŸ₯³