Skip to content

Instantly share code, notes, and snippets.

View choudharymanish8585's full-sized avatar
💭
Never Settle

Manish Choudhari choudharymanish8585

💭
Never Settle
View GitHub Profile
//Add standard object list here if any new standard object supports change data events
//At the time of winter19 below object support change data events
window.supportedObjectForChangeEvents = ['Account','Asset','Campaign','Case','Contact','ContractLineItem','Entitlement','Lead',
'LiveChatTranscript','Opportunity','Order','OrderItem','Product2','Quote','QuoteLineItem','ServiceContract'];
<!-- This event will be fired whenever new record change has been captured by RecordChangeEventHandler component -->
<aura:event type="COMPONENT" description="Event template">
<aura:attribute name="recordData" type="Object" />
</aura:event>
<aura:component access="global">
<!-- ChannelName, which needs to subscribed -->
<aura:attribute name="channelName" type="String" required="true"/>
<!-- Save the reference of current subscription, which can be unsubscribe later on -->
<aura:attribute name="subscription" type="Object"/>
<!-- This event is fired when a component is destroyed.
Handle this event if you need to do custom cleanup when a component is destroyed.-->
<aura:handler name="destroy" value="{!this}" action="{!c.unsubscribe}"/>
({
/**
* This function calls subscribe method of empApi component
* to receive events
* @author Manish Choudhari
* @version 1.0.0
* */
subscribe: function(component, event, helper) {
// Get the empApi component.
<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName"
access="global"
controller="RecordChangeCaptureLightningController">
<aura:attribute name="channelName" type="String" default="" />
<aura:attribute name="autoRefresh" type="String" default="Yes" />
<aura:attribute name="isSupported" type="Boolean" default="false" />
<!--Loading list of supported object for change events
- This can be configured in a custom setting or custom metadata type also
({
checkCompatibility : function(component, event, helper){
//get current object
var objectName = component.get("v.sObjectName");
//Check is object name is not undefined/null
if(objectName){
//Get channel name for change event
var channelName = helper.getChannelName(objectName);
({
/*
* This method will call the server side action to get user name
* Once user name retrieved, it will show a warning toast to the user
* */
getUser : function(component, userId, eventType, entityName) {
var action = component.get("c.getUserName");
action.setParams({
"userId" : userId
<!-- Show auto refresh selection in app builder page -->
<design:component>
<design:attribute name="autoRefresh" label="Auto refresh the page?" datasource="Yes,No" default="Yes" />
</design:component>
{
"data":{
"event":{
"createdDate":"2018-10-18T01:17:26.855Z",
"replayId":61,
"type":"updated"
},
"sobject":{
"Type":"Customer - Channel",
"Phone":"(785) 241-6201",