Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
sendCustomEvent() for Lightning Experience
Arguments
| Name | Type | Description |
|---|---|---|
| argumentObj | Object | An object containing all the arguments to be passed into this method. |
argumentObj
| Name | Type | Description |
|---|---|---|
| recordId | String | The ID of the event that you want to customize. |
| type | String | The name of the custom event type. |
| data | String | The data attached to the custom event. |
Sample Code
This example publishes a custom event and logs the result.
Component Code:
1<aura:component implements="flexipage:availableForAllPageTypes" access="global" description="Conversation toolkit api sample">
2 <aura:attribute name="recordId" type="String" />
3 <lightning:conversationToolkitAPI aura:id="conversationKit" />
4 <ui:button label="sendCustomEvent" press="{!c.sendCustomEvent}" />
5</aura:component>Controller Code:
1({
2 sendCustomEvent: function(cmp, evt, helper) {
3 var conversationKit = cmp.find("conversationKit");
4 var recordId = cmp.get("v.recordId");
5 var type = "myCustomEventType";
6 var data = "myCustomEventData";
7 conversationKit.sendCustomEvent({
8 recordId: recordId,
9 type: type,
10 data: data
11 })
12 .then(function(result){
13 if (result) {
14 console.log("Successfully sent custom event");
15 } else {
16 console.log("Failed to send custom event");
17 }
18 });
19 }
20})The custom event type must match the name of your custom event. Replace myCustomEventType with your own custom event name.
Response
Returns a Promise. Success is indicated if the promise is fulfilled. Failure is indicated if the catch clause is invoked.