Newer Version Available
setServicePresenceStatus
Sets an agent's presence status to a status with a particular ID. Available in API
versions 32.0 and later.
Syntax
1sforce.console.presence.setServicePresenceStatus(statusId:String,
2 (optional) callback:function)Arguments
| Name | Type | Description |
|---|---|---|
| statusId | String | The ID of the presence status you want to set the agent to. 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–Visualforce
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<apex:page>
18 <apex:includeScript value="/support/console/32.0/integration.js"/>
19 <a href="#" onClick="testSetStatus('0N5xx00000000081');return false;">Set Presence Status</a>
20
21 <script type="text/javascript">
22 function testSetStatus(statusId) {
23 //Gets the Salesforce Id of the presence status that’s assigned to the current user through permission set or profile.
24 //These values are for example purposes only
25 sforce.console.presence.setServicePresenceStatus(statusId, function(result) {
26 if (result.success) {
27 alert('Set status successful');
28 alert('Current statusId is: ' + result.statusId);
29 alert('Channel list attached to this status is: ' + result.channels); //printout in console for lists
30 } else {
31 alert('Set status failed');
32 }
33 });
34 }
35 </script>
36</apex:page>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 if setting the agent’s status wasn’t successful. |
| 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. |