function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhishekh JaiswalAbhishekh Jaiswal 

Lightning Console JavaScript API is not working

Hi, 

We are integrating omnichannel with CTI where we want to get and set omnichannel channel status.

The issue is we are not able to set the status and get the changed status event in "Lightning Console JavaScript API".

I have tried with this below code.

1:

MethodComponet

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<lightning:omniToolkitAPI aura:id="omniToolkit" />
<lightning:button label="Set Status" onclick="{! c.setStatus }" />
</aura:component>
 

MethodController

({
setStatus: function(cmp, evt, hlp) {
var omniAPI = cmp.find("omniToolkit");
omniAPI.setServicePresenceStatus({statusId: "0N5xx0000000002"}).then(function(result)
{
console.log('Current statusId is: ' + result.statusId);
console.log('Channel list attached to this status is: ' + result.channels);
}).catch(function(error) {
console.log(error);
});
}
})

 

2:

EventComponent

<aura:component implements="flexipage:availableForAllPageTypes"access="global" >
<lightning:omniToolkitAPI aura:id="omniToolkit" />
<aura:handler event="lightning:omniChannelStatusChanged" action="{! c.onStatusChanged
}"/>
</aura:component>


EventController

({ onStatusChanged : function(component, event, helper) { console.log("Status changed."); var statusId = event.getParam('statusId'); var channels = event.getParam('channels'); var statusName = event.getParam('statusName'); var statusApiName = event.getParam('statusApiName'); console.log(statusId); console.log(channels); console.log(statusName); console.log(statusApiName); }, })
Arya asthanaArya asthana
Hi Abhishek,
Kindly check below two links i hopes it must be useful for you.

https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_js_getting_started.htm
https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lex_getting_started.htm

Abhishek if you still face challenges and are not able to do the work you can reach me for small concept salesforce lightning training (https://www.maxmunus.com/page/Salesforce-Lightning-Training) / Salesforce training (https://www.maxmunus.com/page/Online-Training/Salesforce-Training) and project support.

https://www.maxmunus.com/page/Salesforce-Lightning-Training

OR you can also email me at contact@maxmunus.com, +919035888988
 
Abhishekh JaiswalAbhishekh Jaiswal

Thanks for the reply Asthana,

I have already gone through the above links but it's not helpful, as you can see that I have tried it in EventComponent and EventController but not getting the response.