You need to sign in to do that
Don't have an account?

Code to auto sign into Omni-Channel
I'm working on a lightning component for the service cloud utility bar which should essentially auto log you into Omni Channel once you have been logged into the service console.
In the lightning component controller, I have the following:
In the lightning component controller, I have the following:
({ doInit: function(cmp, evt, hlp) { window.setTimeout( $A.getCallback(function() { var omniAPI = cmp.find("omniToolkit"); omniAPI.setServicePresenceStatus({ statusId: "0N561000000027Y", callback: function(result) { if (result.success) { console.log('Set status successful'); console.log('Current statusId is: ' + result.statusId); console.log('Channel list attached to this status is: ' + result.channels); } else { console.log('Set status failed'); } } }); }), 100 ) //helper.setStatus(cmp, evt, hlp); }, })In my component I have:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" > <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <lightning:omniToolkitAPI aura:id="omniToolkit" /> <!-- <lightning:utilityBarAPI aura:id="utilitybar" /> <lightning:button label="Get Status" onclick="{! c.getStatus }" /> <lightning:button label="Set Status" onclick="{! c.setStatus }" /> --> </aura:component>How do I go about getting this to load automatically? If I click on the lightning component, I will get signed into Omni-channel. It would be ideal to have this happen on load.
Use this in your component
<aura:component implements="lightning:backgroundUtilityItem" access="global" >
ANd then add it to the utility items.
reference https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_js_lightning_background_utility_item.htm
This works, however if the user refreshes the page, the named presence ID fires again. How could you make is so that it only tiggered if 'Offline'?