Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

login

Logs an agent into Omni-Channel with a specific presence status. You also can use this method to reconnect to Omni-Channel after a connection error. Available in API versions 32.0 and later.

Syntax

1sforce.console.presence.login(statusId:String, (optional) callback:function)

Arguments

Name Type Description
statusId String The ID of the presence status. 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 is logged in with the presence status associated with statusId.

Sample Code–Visualforce

1<apex:page>
2    <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <a href="#" onClick="testLogin('0N5xx00000000081');return false;">Log In to Omni-Channel</a> 
4
5    <script type="text/javascript">
6        function testLogin(statusId) {
7            //Gets the Salesforce ID of the presence status entity which the current user has been assigned through their permission set or profile. 
8            //These values are for example purposes only.
9            sforce.console.presence.login(statusId, function(result) { 
10                if (result.success) { 
11                    alert('Login successful');
12                } else {
13                    alert('Login failed');
14                }
15           }); 
16        }
17    </script>
18</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 the login was successful; false if the login wasn’t successful.