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
Carlos CiceroCarlos Cicero 

How to work with <lightning:omniToolkitAPI aura:id="omniToolkit" /> ?

I am doing a POC with lightning:omniToolkitAPI 

I created and aura component to set in the background of the lightning service console. When the user changed the status I am calling the method getAgentWorks of the API but it is not calling at all and the API object is getting empty {} when printed the log  console.log( JSON.stringify(omniAPI));

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

controller
({
    onStatusChanged: function(cmp, evt, hlp) {
        console.log("Status changed.");
       hlp.getAgentWork(cmp, evt,hlp);
    }        
})
Helper
({
    getAgentWork: function(cmp, evt,hlp) {
        var omniAPI = cmp.find("omniToolkit");  
         console.log( JSON.stringify(omniAPI));
        omniAPI.getAgentWorks({
            callback: function(result) {
                 console.log("inside callback getAgentWork ");
                if (result.success) {
                    
                    console.log('Get work items successful');
                    
                } else {
                    console.log('Get work items failed');
                }
            }
        });
        console.log("getAgentWork call");
    }
})

 
VinayVinay (Salesforce Developers) 
Hi Carlos,

Check below examples for <lightning:omniToolkitAPI aura:id="omniToolkit>

https://www.infallibletechie.com/2022/04/how-to-set-omni-channel-status-from.html
https://www.coursehero.com/file/p7uft73q/var-omniAPI-cmpfindomniToolkit-omniAPIgetAgentWorksthenfunctionresult-var-works/
https://salesforce.stackexchange.com/questions/249832/how-to-get-omnitoolkitapi-javascript-object

Thanks,