Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. // Subscribe to an event
  2. empApi.subscribe(channel, replayId, $A.getCallback(eventReceived => {
  3. // Process event (this is called each time we receive an event)
  4. console.log('Received event ', JSON.stringify(eventReceived));
  5. }))
  6. .then(subscription => {
  7. ...
  8. });
  9.  
  10. {
  11. "data": {
  12. "schema": "xxxx",
  13. "payload": {
  14. "My_Custom_Field1__c": "value",
  15. "My_Custom_Field2__c": "value",
  16. "CreatedById": "xxx",
  17. "CreatedDate": "xxx"
  18. },
  19. "event": {
  20. "replayId": 11
  21. }
  22. },
  23. "channel": "/event/My_Event__e"
  24. }
  25.  
  26. empApi.subscribe(channel, replayId, $A.getCallback(eventReceived => {
  27. // Process event (this is called each time we receive an event)
  28. console.log('Received event ', JSON.stringify(eventReceived));
  29.  
  30. // parse the JSON
  31. var jsonRes = JSON.parse(JSON.stringify(eventReceived));
  32.  
  33. // retrieve the custom field values now
  34. var myCustomField1 = jsonRes.data.payload.My_Custom_Field1__c;
  35. }))
  36. .then(subscription => {
  37. ...
  38. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement