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 to presence. 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. |
| callback | function | JavaScript method to call when the agent’s status is changed to the presence status associated with statusId. |
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({
5 statusId: "0N5xx0000000006",
6 callback: function(result) {
7 if (result.success) {
8 console.log('Set status successful');
9 console.log('Current statusId is: ' + result.statusId);
10 console.log('Channel list attached to this status is: ' + result.channels);
11 } else {
12 console.log('Set status failed');
13 }
14 }
15 });
16 }
17})Response
This method is asynchronous so it returns its response in an object in a callback method. The response object contains the following properties:
| Name | Type | Description |
|---|---|---|
| success | boolean | true if setting the agent’s status was successful; false otherwise. |
| 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. |