---
schema_version: "1"
id: 954f2b56fd821bf1325c2a2d8db4e9f284ff3280f5cb6488ce1d3f79a1c0bfe0
title: getDirectoryNumbers() for Salesforce Classic
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/api-cti/guides/sforce-api-cti-getdirectorynumbers.md
canonical_url: https://developer.salesforce.com/docs/service/api-cti/guide/sforce-api-cti-getdirectorynumbers.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3cbaa40c45bddabf102d06d25d7c4a8256420fa534b59919b4ba2f2fe000292a
products:
  - Open CTI Developer Guide
  - Service Cloud Developer Content
---

# getDirectoryNumbers() for Salesforce Classic

## Usage

Returns the list of phone numbers from the call center's directory. This method is only available in API version 31.0 or later.

## Syntax

```javascript
sforce.interaction.cti.getDirectoryNumbers(isGlobal:boolean, callCenterName:String, (optional) callback:function, (optional) resultSetPage:Integer, (optional) resultSetPageSize:Integer)
```

## Arguments

|Name|Type|Description|
|------|------|-------------|
|`isGlobal`|boolean|Set to `true` to return directory numbers from the global call center, or `false` to return directory numbers specific to a call center.|
|`callCenterName`|string|Specifies the call center name on which to return directory numbers. If `isGlobal` is `false` and this field is not specified, all directory numbers are returned.|
|`callback`|function|JavaScript method executed when the API method call is completed.|
|`resultSetPage`|integer|Represents the page number of the list of results to return. This number starts at 0.|
|`resultSetPageSize`|integer|Sets the maximum number of phone numbers to retrieve. Defaults to 5000; maximum is 10000. If `hasNext` returns `true` in the `callback`, use this argument with `resultSetPage` to get the next page of results. For example, if `resultSetPageSize` is 5000 and `resultSetPage` is 0, the first 5000 phone numbers are returned; if `resultSetPage` is 1, the next 5000 are returned.|


## Sample Code–JavaScript

<!-- javascript set_clipboard -->
```javascript
<html>
<head>
   <script src="https://domain:port/support/api/31.0/interaction.js"></script>
   <script type="text/javascript">
       var callback = function (response) {
           if (response.result) {
                  alert(response.result);
            } else {
                   alert(response.error);
           }
        };

       var isGlobal = false; //Do not return directories from the global call center
       var callCenterName = 'My Call Center'; //Call center name of directory numbers to return

       function getDirectoryNumbers() {
                sforce.interaction.cti.getDirectoryNumbers(isGlobal, callCenterName, callback);
        }
</script>
</head>
<body>
       <button onclick="getDirectoryNumbers();">Get Directory Numbers</button>
</body>
</html>
```

## Response

|Name|Type|Description|
|------|------|-------------|
|`result`|string|Returns a JSON string that represents the list of phone numbers from the specified call center name. Each phone number element contains a call center name, phone, and description.|
|`error`|string|If the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.|


Example `result`:

```javascript
{ directoryNumbers:
   [ 
      {callCenterName:'Demo Call Center', name:'Sales Cloud', phone:'415-555-1212', description:'Sales Cloud additional number'},
      {callCenterName:'Demo Call Center 2', name:'Service Cloud', phone:'415-555-3434', description:'Service Cloud additional number'},
   ], 
   hasNext: false
} 
```

