screenPop() for Lightning Experience

Usage

Pops to a new location as specified by the input type and parameters. This method is available in API version 38.0 or later.

note: Open CTI for Lightning Experience doesn't support the softphone layout field Screen pops open within when the value is New browser window or tab. In Lightning Experience, the default value is Existing browser window.

Syntax

sforce.opencti.screenPop({
    type: sforce.opencti.SCREENPOP_TYPE.*, //Review the arguments section.
    params: OBJECT //Depends on the SCREENPOP_TYPE. Review the arguments section.
});

Arguments

Name Type Description
type string Required. The screen pop target. Valid values: <ul><li>SOBJECT</li><li>URL</li><li>OBJECTHOME</li><li>LIST</li><li>SEARCH</li><li>NEW_RECORD_MODAL</li><li>FLOW</li></ul>
params object Required. Arguments for the specified type value. See Type-Specific params Values.
defaultFieldValues object Optional. Pre-populates fields on a new-entity screen pop when no search results exist for an inbound call. Only applies when type is NEW_RECORD_MODAL. See the sample code below for an example.
callback function Optional. JavaScript method executed when the API call completes.

Type-Specific params Values

The params argument takes different fields depending on the value of type.

  • SOBJECT

    • :

      params: { recordId: STRING }
      

      Where recordId is the ID of the standard or custom object in Salesforce.

  • URL

    • :

      params: { url: STRING }
      

      The URL must be a relative path. For details on the url parameter, see force:navigateToURL in the Lightning Aura Components Developer Guide.

  • OBJECTHOME

    • :

      params: { scope: STRING }
      

      Pops to the home page of an object such as a case or account. For details on the scope parameter, see force:navigateToSObject in the Lightning Aura Components Developer Guide.

      Example: { scope: "Account" }

  • LIST

    • :

      params: { listViewId: STRING, scope: STRING }
      

      For details on the listViewId and scope parameters, see force:navigateToList in the Lightning Aura Components Developer Guide.

  • SEARCH

    • :

      params: { searchString: STRING }
      

      Pops to the Top Results section of the search page. The string must be at least 3 characters.

  • NEW_RECORD_MODAL

    • :

      params: {
          entityName: STRING,      // required
          defaultFieldValues: object  // optional
      }
      

      entityName is the API name of the object, such as Account, Case, Contact, or Lead.

      For custom objects, use the format {objectName}__c (two underscores, default namespace).

      If your org has a namespace, use namespace__{objectName}__c.

      To pop to a new person account modal, use Account.

  • FLOW

    • :

      params: {
          flowDevName: 'Flow_Dev_Name',
          flowArgs: [{ name: 'Name', type: 'Type', value: 'Value' }]
      }
      

      Pops to the target flow. Use flowArgs to pass additional arguments such as the caller's phone number or a list of matching records.

      Only active UI screen flows of type Flow can be popped. Arguments in flowArgs must be declared as variables inside the flow, or they are silently ignored at runtime. See the FlowVariable section in the topic on Flow in the Metadata API Developer Guide.

Sample Code–HTML and JavaScript with a callback

<!-- html set_clipboard -->
<html>
	<head>
   <script type="text/javascript" src="http://domain:port/support/api//lightning/opencti_min.js"></script>
   <script type="text/javascript">							
 	var callback = function(response) {
         if (response.success) {
            console.log('API method call executed successfully! returnValue:', response.returnValue);
         } else { 
            console.error('Something went wrong! Errors:', response.errors);
         }
      	};
       	function screenPop() {
                	sforce.opencti.screenPop({type: sforce.opencti.SCREENPOP_TYPE.OBJECTHOME, params: {scope:"Account"}, callback: callback  });
        	}
</script>
</head>
<body>
       <button onclick="screenPop();">screenPop</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 Returns true if the API method call was invoked successfully, false otherwise.
returnValue object This API method doesn’t return this object. The returnValue is always null.
errors array If the API call was successful, this variable is null. If the API call failed, this variable returns an array of error messages.