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

Flexcards have the ability to trigger and listen to two kinds of events: Custom and Pubsub events.

Custom Events: Facilitate the transmission of information between a child and its parent. This can occur between a child Flexcard and its parent Flexcard, or between an element and the Flexcard to which it belongs.
Pubsub Events: Allows communication between two separate components. This could occur between two separate Flexcards on the same Lightning page, known as sibling Flexcards, or between a Flexcard and an Omniscript. 

In this post I will discuss about Pub/Sub event. Consider we have omniscript and flexcard individually on home page when an update happens we need to show those details in flexcard. To achieve this we can use pub/sub event.

Step 1: Create a omniscript according to your requirement. I'm trying to create Contact record by using Step element and data raptor post action.

Now to trigger the flexcard we need to configure the messaging frame work when an update happens.
Click on properties of DataRaptorPost Action and scroll down till message framework and check the pub/sub checkbox. If you need to pass inputs from omniscript to flexcard we can use pass key/value pair.

Step 2: Configure DataRaptor Extarct which we use in flexcard as a datasource.
Step 3:  Configure Data Source from setup of the flexcard to display the contacts based on created date.
We can fetch the contacts by using data source as data raptor by mentioning the dataraptor name and click on save and fetch.
Now drag and drop data table element into the canvas.
To trigger this flexcard configure event listener under setup of the flexcard.
Note: Remember when we are using pub/sub salesforce provides some standard channel names like omniscript_action, omniscript_step.
In our scenario i'm using omniscript_action because i'm triggering flexcard after performing action from action elements. we can use omniscript_step to trigger the flexcard after step.
Click on Add New from event listener and configure as mentioned below.
From Action Drop-Down select action type as card, Data source as DataRapotor and choose the dataraptor which we have configured in Data source of the flexcard from setup [both need to be same].
Click save and fetch and again save.
Activate the flexcard and omniscript and place those components on home page, record page according to requirement. 
Note: If required disable the repeat options under setup from flexcard before activating.
Output: Before record creation.
After new contact record creation.
--------------------------------------------------------------------------------------------------------------------
If we need to use the values from omniscript we can configure {action.contactId} in the event listener as shown in below screen shots. 



Comments

Popular posts from this blog

Vlocity Facts #01 | OmniStudio DataRaptors

Vlocity Facts #34 || Getting the details from the URL in a FlexCard and an Omniscript