Vlocity Facts #49 ||Using Integration Procedure as Rest API

In Salesforce OmniStudio, we can fetch the data, create records or perform update operations by exposing an Integration Procedure to third-party applications. Instead of relying on Apex classes or methods, the Integration Procedure handles the data processing and record creation, allowing us to seamlessly create, fetch, update records in Salesforce from external systems.
In this post will show how to create, update a Account, Case and user records by using Integration Procedure as REST API.

Follow these Steps to implement the use case.
To create records we need to get all the required the fields. In Integration procedure by using set values we can identify whether we got all required fields to create, update the records.

For this example I'm going to use below mentioned json.

{
    "accountDetails": {
        "FirstName""Community",
        "LastName""User6",
        "Email"".com",
        "DateOfBirth""1999-12-12",
        "Premium""Yes",
        "Partner""Gold"
    },
    "caseDetails": {
        "Subject""Performance Issue",
        "Description""While I'm playing game it is getting over heated",
        "Type""Laptop",
        "Priority""High",
        "Mobile Number""999999999",
        "SIDN""9999",
        "CaseReason""Performance"
    }
}

Start by creating Integration Procedure.

Error Handling Scenario
Set Values: By using set values I will get to know whether required fields I have received or not.

Response Action: Based on the Boolean value true, false I will conditionally execute the response action. If required fields are missing I will send "Required fields are missing to create case." by using response action.

Happy Path: Account, Case and User record creation.
  • Create a load data raptor - Select the ‘Interface Type’ as ‘Load’ and ‘Output Type’ as ‘SObject’ and click Save, select ‘Account’, 'Case' in the Objects tab.
  • I'm Using "Upsert" option on Email, Last Name, First Name field to update the existing account details.

  • Add the Input JSON Path and Domain Object Field or paste the json in "Input Json" and use Quick match to map the JSON path and Domain Object.
Use Data Mapper Extract to extract the Account and case details for creating the user record.
To get the existing User Details I have added User object to get the Id for upsert options in next step. 
I'm using one more IP to create User record. Due to salesforce limitation which we cannot perform the creation at a time on Setup and Non-setup objects. 
In remote options I have added one parameter "useFuture" as true.
Child Integration Procedure:
And Data Mapper Post to create/update User records.

Using "Email Action" to send email after case creation.

To test the above Integration Procedure as rest API
To test the integration, you can use tools like Workbench, Postman, or others. In this example, we will use Workbench. First, log in to Workbench, navigate to the 'Utilities' tab, and select 'REST Explorer.' Then, choose the 'POST' method instead of 'GET,' and prepare the URL as outlined in the next step.

/services/apexrest/{namespace}/v1/integrationprocedure/{Type}_{SubType}/

I have replaced the {namespace} in the URL with the correct namespace for my organization (e.g., OmniStudio), and substituted {Type}_{SubType} with the appropriate type and subtype of the Integration Procedure created earlier. The final URL would look like this

/services/apexrest/omnistudio/v1/integrationprocedure/Salesforce_Hackathon/

Response of the Integration Procedure

In conclusion: Instead of utilizing Apex code for the REST API, we leveraged OmniStudio Integration Procedures and DataRaptors to expose Salesforce to third-party applications, successfully creating records in Salesforce. By implementing this OmniStudio feature, we provide a seamless and efficient method for performing REST-based web services without the need for custom code.

OutPut:













Comments

Popular posts from this blog

Vlocity Facts #01 | OmniStudio DataRaptors

Vlocity Facts #44 || Communication between Omniscript and Flexcard [Pub/Sub]

Vlocity Facts #45 || Pop-Up Screen and Navigating to the Next Step in Omniscript by using LWC