Newer Version Available
setServicePresenceStatus for Lightning Experience
Sets an agent's presence status to a status with a particular ID. If the specified
agent is not already logged in, we log in the agent with the presence status. This method
removes the need for you to make more calls.
Arguments
| Name | Type | Description |
|---|---|---|
| statusId | string | The ID of the presence status to which you want to set the agent. Agents must be given access to this presence status through their associated profile or permission set. |
Sample Code
Component code:
1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2 <lightning:omniToolkitAPI aura:id="omniToolkit" />
3 <lightning:button label="Set Status" onclick="{! c.setStatus }" />
4</aura:component>Controller code:
1({
2 setStatus: function(cmp, evt, hlp) {
3 var omniAPI = cmp.find("omniToolkit");
4 omniAPI.setServicePresenceStatus({statusId: "0N5xx0000000002"}).then(function(result) {
5 console.log('Current statusId is: ' + result.statusId);
6 console.log('Channel list attached to this status is: ' + result.channels);
7 }).catch(function(error) {
8 console.log(error);
9 });
10 }
11})Response
This method returns a promise that, upon success, resolves to an object containing the following fields.
| Name | Type | Description |
|---|---|---|
| statusName | string | The name of the agent’s current presence status. |
| statusApiName | string | The API name of the agent’s current presence status. |
| statusId | string | The ID of the agent’s current presence status. |
| channels | JSON string of channel objects | Returns the IDs and API names of the channels associated with the presence status. |