# getSoftphoneLayout() for Lightning Experience

## Usage

Returns the softphone layout of the current user. This method is available in API version 38.0 or later.

The Open CTI for Lightning Experience methods `screenPop()` and `searchAndScreenPop()` don't support `screenPopSettings`.

## Syntax

```javascript
sforce.opencti.getSoftphoneLayout({
  callback: FUNCTION,
});
```

## Arguments

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

## Sample Code–HTML and JavaScript

```html
<html>
  <head>
    <script
      type="text/javascript"
      src="https://domain:port/support/api//lightning/opencti_min.js"
    ></script>
    <script type="text/javascript">
      var callback = function (response) {
        if (response.success) {
          alert(response.returnValue);
        } else {
          console.error(response.errors);
          alert("Something went wrong. Please check error information in developer console.");
        }
      };

      function getSoftphoneLayout() {
        sforce.opencti.getSoftphoneLayout({
          callback: callback,
        });
      }
    </script>
  </head>
  <body>
    <button onclick="getSoftphoneLayout();">Get Softphone Layout</button>
  </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                                                                                                                                    |
| ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `success`     | boolean | `true` if the API call succeeded and the softphone layout definition is returned in `returnValue`; `false` otherwise.                          |
| `returnValue` | object  | The softphone layout definition if the call succeeded; `null` if it failed. See [returnValue Fields](#returnvalue-fields).                     |
| `errors`      | array   | `null` if the call succeeded. Otherwise, an array of [error messages](/docs/service/api-cti/guide/sforce-api-cti-error-messages-lightning.md). |

## returnValue Fields

The returned object contains three keys, `"Internal"`, `"Inbound"`, and `"Outbound"`, one for each call type. Each call-type object has the these fields.

- `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"`.

    Also contains settings for each screen pop match type: `"NoMatch"`, `"SingleMatch"`, and `"MultipleMatches"`. Each match type has a `screenPopType` field and an optional `screenPopData` field.

| screenPopType value  | screenPopData value                  |
| -------------------- | ------------------------------------ |
| `"PopToEntity"`      | Name of the target object.           |
| `"PopToVisualforce"` | Name of the target Visualforce page. |
| `"PopToSearch"`      | Not present.                         |
| `"PopToFlow"`        | Name of the target flow.             |

## Example returnValue

```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" : {}
  }
}
```
