# getSoftphoneLayout() for Salesforce Classic

## Usage

Returns the softphone layout as a JSON string. This method is only available in API version 27.0 or later.

## Syntax

```javascript
sforce.interaction.cti.getSoftphoneLayout(callback:function);
```

## Arguments

| Name       | Type     | Description                                                       |
| ---------- | -------- | ----------------------------------------------------------------- |
| `callback` | function | JavaScript method executed when the API method call is completed. |

## Sample Code–JavaScript

```javascript
<html>
<head>
   <script type="text/javascript" src="http://domain:port/support/api/27.0/interaction.js"></script>
   <script type="text/javascript">
       var callback = function (response) {
               alert(response.result);
           } 
       // Calls getSoftphoneLayout
       sforce.interaction.cti.getSoftphoneLayout(callback);
</script>
</head>
<body></body>
</html>
```

## Response

This method is asynchronous. The response is returned in an object passed to a callback method. The response object contains the following fields.

| Name     | Type                | Description                                                                                                                               |
| -------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `result` | string              | If the API call was successful, the softphone layout definition is returned as a JSON string. If the API call failed, `null` is returned. |
| `error`  | string or undefined | If the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.               |

The returned JSON string contains three elements, one for each call type:

- `"Internal"`
- `"Inbound"`
- `"Outbound"`

Each call type contains three subsections:

- `"callRelatedFields"`—An array of call-related fields selected to display. Possible values are `"ANI"`, `"DNIS"`, `"SEGMENT"`, and `"QUEUE"`.
- `"objects"`—The set of Salesforce objects selected to display, along with the `Field Label` and `Field Name` (API name) selected to display from each object.
- `"screenPopSettings"`—Contains a `"screenPopsOpenWithin"` field with a value of either `"ExistingWindow"` or `"NewWindow"`, and settings for each screen pop match type: `"NoMatch"`, `"SingleMatch"`, and `"MultipleMatches"`. Each match type contains a `"screenPopType"` field and may also contain a `"screenPopData"` field. If `"screenPopType"` is `"PopToEntity"`, then `"screenPopData"` contains the target object name. If it is `"PopToVisualforce"`, then `"screenPopData"` contains the target Visualforce page name. If it is `"PopToSearch"`, there is no `"screenPopData"` field.

Example `result`:

```javascript
"Internal" : {
   "callRelatedFields" : [
    "ANI",  
    "DNIS", 
   ]
   "objects" : {
    "User" : [ {
      "displayName" : "Name",
      "apiName" : "Name"
     }
    ]
   },
   "screenPopSettings" : {}
  },
  "Inbound" : {
   "callRelatedFields" : [
    "ANI",
    "DNIS",
    "SEGMENT",
    "QUEUE"  
   ],
    "objects" : {
    "Account" : [ {
      "displayName" : "Account Name",
      "apiName" : "Name"
     }
    ]
     
   },
   "screenPopSettings" : {
    "NoMatch" : {
     "screenPopType" : "PopToEntity",
     "screenPopData" : "Contact"  
    },
     
    "SingleMatch" : {
     "screenPopType" : "PopToVisualforce",
     "screenPopData" : "Visualforce_Page_Name"
    },
    "MultipleMatches" : {
     "screenPopType" : "PopToSearch"
    }
   }
  },
  "Outbound" : {
   "callRelatedFields" : [
    "DNIS"  
   ],
   "objects" : {
    "Account" : [ {
      "displayName" : "Account Name",
      "apiName" : "Name"
     }
    ]
   },
   "screenPopSettings" : {}
  }
 }
```
