Question

1
Replies
35
Views
Close popover
Dinesh Kumar Sundaravadivelu (DSundaravadivelu)
TSYS
IT Architect
TSYS
US
DSundaravadivelu Member since 2010 7 posts
TSYS
Posted: December 2, 2020
Last activity: December 7, 2020

Need to embed Nodejs code in section.

I am having a requirements to enable to scripts (which will subscribe some events ) when we click on the button in the section.

I am added some scripts in a section under Cpm-Portal class and added that section in TOP right corner near to the Phone icon.

<script> 

var events = require('events');
var eventEmitter = new events.EventEmitter();

// listener #1
var listner1 = function listner1() {
   console.log('listner1 executed.');
}

// listener #2
var listner2 = function listner2() {
   console.log('listner2 executed.');
}

// Bind the connection event with the listner1 function
eventEmitter.addListener('connection', listner1);

// Bind the connection event with the listner2 function
eventEmitter.on('connection', listner2);

var eventListeners = require('events').EventEmitter.listenerCount
   (eventEmitter,'connection');
console.log(eventListeners + " Listner(s) listening to connection event");

// Fire the connection event 
eventEmitter.emit('connection');

// Remove the binding of listner1 function
eventEmitter.removeListener('connection', listner1);
console.log("Listner1 will not listen now.");

// Fire the connection event 
eventEmitter.emit('connection');

eventListeners = require('events').EventEmitter.listenerCount(eventEmitter,'connection');
console.log(eventListeners + " Listner(s) listening to connection event");

console.log("Program Ended.");

 

  </script>

This script is not get called at the 

***Edited by Moderator: Pooja Gadige to add platform capability tag***
Pega Platform Conversational Channels User Experience Consumer Services Lead System Architect