Home
Home
German Version
Support
Impressum
25.2 Release ►

Start Chat with Collection

    Main Navigation

    • Preparation
      • Connectors
      • Create an InSpire VM on Hyper-V
      • Initial Startup for G7 appliances
      • Setup InSpire G7 primary and Standby Appliances
    • Datasources
      • Configuration - Atlassian Confluence Connector
      • Configuration - Best Bets Connector
      • Configuration - Box Connector
      • Configuration - COYO Connector
      • Configuration - Data Integration Connector
      • Configuration - Documentum Connector
      • Configuration - Dropbox Connector
      • Configuration - Egnyte Connector
      • Configuration - GitHub Connector
      • Configuration - Google Drive Connector
      • Configuration - GSA Adapter Service
      • Configuration - HL7 Connector
      • Configuration - IBM Connections Connector
      • Configuration - IBM Lotus Connector
      • Configuration - Jira Connector
      • Configuration - JVM Launcher Service
      • Configuration - LDAP Connector
      • Configuration - Microsoft Azure Principal Resolution Service
      • Configuration - Microsoft Dynamics CRM Connector
      • Configuration - Microsoft Exchange Connector
      • Configuration - Microsoft File Connector (Legacy)
      • Configuration - Microsoft File Connector
      • Configuration - Microsoft Graph Connector
      • Configuration - Microsoft Loop Connector
      • Configuration - Microsoft Project Connector
      • Configuration - Microsoft SharePoint Connector
      • Configuration - Microsoft SharePoint Online Connector
      • Configuration - Microsoft Stream Connector
      • Configuration - Microsoft Teams Connector
      • Configuration - Salesforce Connector
      • Configuration - SCIM Principal Resolution Service
      • Configuration - SemanticWeb Connector
      • Configuration - ServiceNow Connector
      • Configuration - Web Connector
      • Configuration - Yammer Connector
      • Data Integration Guide with SQL Database by Example
      • Indexing user-specific properties (Documentum)
      • Installation & Configuration - Atlassian Confluence Sitemap Generator Add-On
      • Installation & Configuration - Caching Principal Resolution Service
      • Installation & Configuration - Mindbreeze InSpire Insight Apps in Microsoft SharePoint On-Prem
      • Mindbreeze InSpire Insight Apps in Microsoft SharePoint Online
      • Mindbreeze Web Parts for Microsoft SharePoint
      • User Defined Properties (SharePoint 2013 Connector)
      • Whitepaper - Mindbreeze InSpire Insight Apps in Salesforce
      • Whitepaper - Web Connector - Setting Up Advanced Javascript Usecases
    • Configuration
      • CAS_Authentication
      • Configuration - Alerts
      • Configuration - Alternative Search Suggestions and Automatic Search Expansion
      • Configuration - Back-End Credentials
      • Configuration - Chinese Tokenization Plugin (Jieba)
      • Configuration - CJK Tokenizer Plugin
      • Configuration - Collected Results
      • Configuration - CSV Metadata Mapping Item Transformation Service
      • Configuration - Entity Recognition
      • Configuration - Exporting Results
      • Configuration - External Query Service
      • Configuration - Filter Plugins
      • Configuration - GSA Late Binding Authentication
      • Configuration - Identity Conversion Service - Replacement Conversion
      • Configuration - InceptionImageFilter
      • Configuration - Index-Servlets
      • Configuration - InSpire AI Chat and Insight Services for Retrieval Augmented Generation
      • Configuration - Item Property Generator
      • Configuration - Japanese Language Tokenizer
      • Configuration - Kerberos Authentication
      • Configuration - Management Center Menu
      • Configuration - Metadata Enrichment
      • Configuration - Metadata Reference Builder Plugin
      • Configuration - Mindbreeze Proxy Environment (Remote Connector)
      • Configuration - Personalized Relevance
      • Configuration - Plugin Installation
      • Configuration - Principal Validation Plugin
      • Configuration - Profile
      • Configuration - Reporting Query Logs
      • Configuration - Reporting Query Performance Tests
      • Configuration - Request Header Session Authentication
      • Configuration - Shared Configuration (Windows)
      • Configuration - Vocabularies for Synonyms and Suggest
      • Configuration of Thumbnail Images
      • Cookie-Authentication
      • Documentation - Mindbreeze InSpire
      • I18n Item Transformation
      • Installation & Configuration - Outlook Add-In
      • Installation - GSA Base Configuration Package
      • JWT Authentication
      • Language detection - LanguageDetector Plugin
      • Mindbreeze Personalization
      • Mindbreeze Property Expression Language
      • Mindbreeze Query Expression Transformation
      • SAML-based Authentication
      • Trusted Peer Authentication for Mindbreeze InSpire
      • Using the InSpire Snapshot for Development in a CI_CD Scenario
      • Whitepaper - AI Chat
      • Whitepaper - Create a Google Compute Cloud Virtual Machine InSpire Appliance
      • Whitepaper - Create a Microsoft Azure Virtual Machine InSpire Appliance
      • Whitepaper - Create AWS 10M InSpire Appliance
      • Whitepaper - Create AWS 1M InSpire Appliance
      • Whitepaper - Create AWS 2M InSpire Appliance
      • Whitepaper - Create Oracle Cloud 10M InSpire Application
      • Whitepaper - Create Oracle Cloud 1M InSpire Application
      • Whitepaper - MMC_ Services
      • Whitepaper - Natural Language Question Answering (NLQA)
      • Whitepaper - SSO with Microsoft AAD or AD FS
      • Whitepaper - Text Classification Insight Services
    • Operations
      • Adjusting the InSpire Host OpenSSH Settings - Set LoginGraceTime to 0 (Mitigation for CVE-2024-6387)
      • app.telemetry Statistics Regarding Search Queries
      • CIS Level 2 Hardening - Setting SELinux to Enforcing mode
      • Configuration - app.telemetry dashboards for usage analysis
      • Configuration - Usage Analysis
      • Deletion of Hard Disks
      • Handbook - Backup & Restore
      • Handbook - Command Line Tools
      • Handbook - Distributed Operation (G7)
      • Handbook - Filemanager
      • Handbook - Indexing and Search Logs
      • Handbook - Updates and Downgrades
      • Index Operating Concepts
      • Inspire Diagnostics and Resource Monitoring
      • Provision of app.telemetry Information on G7 Appliances via SNMPv3
      • Restoring to As-Delivered Condition
      • Whitepaper - Administration of Insight Services for Retrieval Augmented Generation
    • User Manual
      • Browser Extension
      • Cheat Sheet
      • iOS App
      • Keyboard Operation
    • SDK
      • api.chat.v1beta.generate Interface Description
      • api.v2.alertstrigger Interface Description
      • api.v2.export Interface Description
      • api.v2.personalization Interface Description
      • api.v2.search Interface Description
      • api.v2.suggest Interface Description
      • api.v3.admin.SnapshotService Interface Description
      • Debugging (Eclipse)
      • Developing an API V2 search request response transformer
      • Developing Item Transformation and Post Filter Plugins with the Mindbreeze SDK
      • Development of a Query Expression Transformer
      • Development of Insight Apps
      • Embedding the Insight App Designer
      • Java API Interface Description
      • OpenAPI Interface Description
    • Release Notes
      • Release Notes 20.1 Release - Mindbreeze InSpire
      • Release Notes 20.2 Release - Mindbreeze InSpire
      • Release Notes 20.3 Release - Mindbreeze InSpire
      • Release Notes 20.4 Release - Mindbreeze InSpire
      • Release Notes 20.5 Release - Mindbreeze InSpire
      • Release Notes 21.1 Release - Mindbreeze InSpire
      • Release Notes 21.2 Release - Mindbreeze InSpire
      • Release Notes 21.3 Release - Mindbreeze InSpire
      • Release Notes 22.1 Release - Mindbreeze InSpire
      • Release Notes 22.2 Release - Mindbreeze InSpire
      • Release Notes 22.3 Release - Mindbreeze InSpire
      • Release Notes 23.1 Release - Mindbreeze InSpire
      • Release Notes 23.2 Release - Mindbreeze InSpire
      • Release Notes 23.3 Release - Mindbreeze InSpire
      • Release Notes 23.4 Release - Mindbreeze InSpire
      • Release Notes 23.5 Release - Mindbreeze InSpire
      • Release Notes 23.6 Release - Mindbreeze InSpire
      • Release Notes 23.7 Release - Mindbreeze InSpire
      • Release Notes 24.1 Release - Mindbreeze InSpire
      • Release Notes 24.2 Release - Mindbreeze InSpire
      • Release Notes 24.3 Release - Mindbreeze InSpire
      • Release Notes 24.4 Release - Mindbreeze InSpire
      • Release Notes 24.5 Release - Mindbreeze InSpire
      • Release Notes 24.6 Release - Mindbreeze InSpire
      • Release Notes 24.7 Release - Mindbreeze InSpire
      • Release Notes 24.8 Release - Mindbreeze InSpire
      • Release Notes 25.1 Release - Mindbreeze InSpire
      • Release Notes 25.2 Release - Mindbreeze InSpire
    • Security
      • Known Vulnerablities
    • Product Information
      • Product Information - Mindbreeze InSpire - Standby
      • Product Information - Mindbreeze InSpire
    Home

    Path

    Sure, you can handle it. But should you?
    Let our experts manage the tech maintenance while you focus on your business.
    See Consulting Packages

    Whitepaper

    Table of ContentsPermanent link for this heading


    IntroductionPermanent link for this heading

    This document describes the integration of Mindbreeze InSpire Insight Applications with Salesforce.

    A simple use case, is for example to embed an Insight App in a Salesforce page where a user can directly make use of the search results that are returned and provided by the Mindbreeze appliance. For detailed step-by-step instructions, you can either create a Lightning component as described in this section or create a Visualforce component as described in this section. After that you can use the Lightning App Builder to add your components as described in this section.

    In addition, the integration of Mindbreeze in Salesforce can be extended by adding the following advanced use cases (as examples):

    • Use case (1): Show the associated documents for a Salesforce Case once a user visits the Case page. This is done by automatically triggering a search (e.g. for the subject field of the case) in the embedded Insight app.
      Further details on the implementation can be found in the following section.
    • Use case (2): Attach a Mindbreeze Inspire search result document to a Salesforce Case. This can be done by adding an action button to the search results (e.g. "Attach To Case"), which helps the user to attach individual documents to the case record.
      Further details on the implementation can be found in the following section.

    Software PrerequisitesPermanent link for this heading

    The descriptions and instructions contained in this document are based on Salesforce.

    Embedding an Insight App via Lightning ComponentPermanent link for this heading

    The Lightning Component framework can be used to embed a Mindbreeze Insight App in a Salesforce page.

    In this section, you will create a simple lightning component that hosts your Mindbreeze Insight app within an iframe. Then, you will use the lightning app builder to drag and drop the new component into your Salesforce Home page.

    For more complex interaction that requires communication between the Salesforce object and your Mindbreeze Insight App, please refer to the next section here where the alternative Visualforce page component must be used.

    Please follow these steps to create a lightning component:

    1. In Salesforce, click the top right gear icon then select Developer Console.
    2. In the developer console, select File > New > Lightning Component.
    3. Name the component (e.g. Mindbreeze)
    4. Select Lightning Record Page, and select Submit.
    5. Replace the contents of the component with this code:

    <aura:component implements="flexipage:availableForAllPageTypes" access="global">

           <iframe src="https://myorganization.myInsightApp:<port#>"

                   width="100%"

                   height="800px"

                   frameBorder="none"

                   scrolling="auto" />

    </aura:component>

    Note: Adjust the height (in pixels) to fit in the place of the hosting salesforce page.

    1. Click File > Save.
    2. Insert the new lightning component into your Salesforce Home page using the steps described in the section Lightning App Builder.

    Embedding an Insight App via Visualforce PagePermanent link for this heading

    Visualforce is a framework that allows developers to build custom user interfaces that can be hosted natively on the Lightning platform. In one Visualforce (VF) page, you can directly add HTML tags, CSS and JavaScript via <script> tags.

    In this section, you will create a VF page that hosts your Mindbreeze Insight app. Then, you will use the lightning app builder to drag and drop the new component into a Case record page.

    Please follow these steps to create a Visualforce (VF) page:

    1. In Salesforce, click on the gear icon and then select Setup.
    2. Search for and select Visualforce Pages.
    3. Click New.
    4. Enter a Label (e.g. Mindbreeze_Search_Page). The Name is filled automatically.
    5. Select the checkbox: Available for Lightning Experience, Experience Builder Sites, and the mobile app
    6. Add the Mindbreeze Insight App snippet into the Visualforce Markup.
    7. Note: To create an Insight App, please refer to the following documentation Here
    8. Click Save.
    9. In Salesforce, navigate to a Case record page. Then insert your newly created Visualforce page  as described in this section Lightning App Builder

    Now, your Mindbreeze Insight App is embedded into the Case record page:

    Lightning App Builder to add componentsPermanent link for this heading

    In this section, you will see how the Salesforce lightning app builder is used to insert components (e.g Custom Lightning component or Visualforce page) into your target Salesforce page.

    Please apply the following steps:

    1. In Salesforce, navigate to the target record (e.g. Home, Case, …etc.) page.
    2. Click on the top right gear icon and select Edit Page.
    3. In the middle pane. Choose a place and click on Add Component(s) Here
    4. From the (left) side menu, choose Visualforce or Custom > Your_Ligntining_Component.
    5. If you select VisualForce, from the (right) setting panel, select the VF page name, show or hide the label checkbox, and enter a suitable height (in pixels) for the VF page (e.g. 800).
    6. Click Save.
    7. Click Activate.
    8. Click Assign as Org Default, then click Next and then Save.
    9. Click the blue back button () to exit Lightning App Builder and return to the home page.

    Use Case Set the case record Subject field as a search query in the VF search pagePermanent link for this heading

    This section describes how to send the value of the Subject field from the case record page to the VF search page to automatically search for the subject value when an agent initially visits a Case record page.

    Please apply the following steps:

    1. In Salesforce, click on the top right gear icon and select Setup.
    2. Search for and select Visualforce pages.
    3. Choose the existing VF page. (e.g. Mindbreeze_search_page)
    4. Click on Edit.
    5. In the Visualforce Markup:
      1. Add the Case standard controller to the first line:

        Code Before:
        <apex:page>

        Code After:
        <apex:page standardController="Case">
    1. 5.2. Edit the Mindbreeze <script> tag at the bottom of the page:

      Code Before:
      <script>
        Mindbreeze.require(["client/application"], function(Application){

           var application = new Application();

        });

      </script>


      Code After:
      <script>
         Mindbreeze.require(["client/application"], function(Application){

            var subject = "{! Case.Subject }";
            var App = Application.extend({

                prepareModels: function() {

                   this.setUnparsedUserQuery(subject);

                }

             });

             var application = new App();

         });

      </script>
  • Now return to the Case record page. Refresh the page, the Case subject field is now triggered as a search query into your insight app.

    Use Case Attach search results to a case recordPermanent link for this heading

    This section describes how to extend the existing integration by adding a new custom action button Attach To Case for each search result. Triggering this action button will attach the search result to the Case record page. In addition, you will create a new custom lightning component to fetch all the attached results of a visited Case and displays them in a table view.

    Step 1 Data modeling via custom objectsPermanent link for this heading

    In this step, you will create a custom object and add some fields to it. These fields will be displayed when a search result is attached to the case. A field can be considered as a one-to-one map of a search result property.

    Example:

    If you are interested to show the following search result properties (title, URL, source, and author), then you must create equivalent fields respectively and add them to your custom object.

    Later on, we will show you how the mapping between the search result properties and the custom fields is done, then how the lightning component displays those fields in a table view in the case record page.

    Please apply the following steps:

    • In Salesforce, click on the settings gear icon and choose Edit Object.
    • Click Object Manager to view all objects.
    • Click Create in the dropdown menu and Select Custom Object.
    • Fill in the fields Label and Plural Label. Object Name is set automatically.
    • Click Save.
    • From the left menu. Click Fields & Relationships.
    • Click New.
    • Choose a Data Type (e.g. Text) and click Next.
    • Enter the fields Field Label and a Length. Field Name is automatically set.
    • Click Next, Next, and Save.
    • Repeat the same steps to add the remaining fields.
    • Data Type
    • Label
    • Length
    • URL
    • Result Url
    • N/A
    • Text
    • Source
    • 255
    • Text
    • Author
    • 255
    • Create a Master-Detail relationship with the Case standard object:
      • Click Fields & Relationships. Click New.
      • Choose Data Type: Master-Detail Relationship.
      • Select Case from the “Related To” dropdown.
      • Enter a Field Label. (e.g. Case).
      • Click Next, Next, Next, and then Save.
      • Note down the API Name. (e.g. Case__c).
    • Delete the default view from the Case layout:
    • Return back to object manager list:

    • Choose Case.
    • From left menu, choose “Case Page Layouts”.
    • Choose your layout from the table. (e.g. Case Layout)
    • Scroll down until you find the attached Results table.
    • Delete it by pressing the minus icon
    • Click Save.

    Step 2 Create an Apex custom controllerPermanent link for this heading

    Custom controllers contain custom logic and data manipulation that can be used by a Visualforce page. For example, a custom controller can retrieve a list of items to be displayed and can create or delete records of a custom objects.

    In this step, you will create the controller AttachResultController, which will do the following:

    • Fetch the attached results of a certain case. (Used by the lightning component to display the case attached results in a table view).
    • Remove an attached result from a case.
    • Attach a result to a Case object. (Fired when the Attach To Case action button is clicked)


    Please apply the following steps:

    • In Salesforce, click on the settings gear icon and choose Setup.
    • Search for and select Apex Classes.
    • Click New.
    • Add the following code snippet:

    public class AttachResultController {

        public AttachResultController(ApexPages.StandardController controller) {

        }

        public String ValueReturned {get; set;}

        public void attachResultToCase() {

          Id caseId = System.currentPageReference().getParameters().get('Id');

          String resultName = ApexPages.currentPage().getParameters().get('resultName');

          String resultUrl = ApexPages.currentPage().getParameters().get('resultUrl');

          String source = ApexPages.currentPage().getParameters().get('source');

          String author = ApexPages.currentPage().getParameters().get('author');  

          List<Attached_Result__c> existingAttachedResults = [

            SELECT Name__c FROM Attached_Result__c

            WHERE Case__r.Id = :caseId AND Name__c = :resultName

          ];

      

          if (existingAttachedResults.size() > 0) {

             this.ValueReturned = 'duplicate record';  

          } else {

             Attached_Result__c newRec= new Attached_Result__c();

             newRec.Name__c = resultName;

             newRec.Result_Url__c = resultUrl;

             newRec.Author__c = author;

             newRec.Source__c = source;

             newRec.Case__c = caseId;

             insert newRec;

             this.ValueReturned = 'reload component';

          }

        }

        @AuraEnabled

        public static List<Attached_Result__c> getAttachedResults(Id recordId) {

            return [

               SELECT Name__c, Result_Url__c, Source__c, Author__c

               FROM Attached_Result__c

               WHERE Case__r.Id = :recordId

            ];

        }

        @AuraEnabled

        public static boolean removeAttachedResult(Id recordId, String name) {

            delete [

              SELECT Name__c FROM Attached_Result__c

              WHERE Name__c =: name AND Case__r.Id = :recordId

            ];

            return true;

        }

    }

    Code Highlights:

    In the function attachResultToCase, in the else block, you have created a new instance of your custom object created previously and then you mapped the search result properties to the fields of the custom object.

    Step 3 Create a new Lightning Component (AttachedResults)Permanent link for this heading

    • In this step, you will create a Lightning Component which will be added to the Salesforce Case page. The component displays the fields of the custom object created in the step 1.

    Please apply the following steps:

    1. In Salesforce, click the gear icon then select Developer Console.
    2. In the developer console, select File > New > Lightning Component.
    3. Name the component AttachedResults, select Lightning Record Page, and select Submit.
    4. Replace the contents of the component with this code:

    <aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="AttachResultController">

        <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

        <aura:attribute name="recordId" type="Id" />

        <aura:attribute name="AttachedResults" type="Attached_Result__c"/>

        <aura:attribute name="AttachedResultsCount" type="String" />

        <aura:attribute name="Columns" type="List" />

        

        <lightning:card class="slds-card_boundary" iconName="standard:case" title="{! 'Case Attached Results (' + v.AttachedResultsCount + ')' }">

            <!-- Attached Results list goes here -->

            <lightning:datatable data="{! v.AttachedResults }"

                                 class="tableHeader"

                                 columns="{! v.Columns }"

                                 keyField="Id"

                                 hideCheckboxColumn="true"

                                 onrowaction="{! c.handleRowAction }"

                                 wrapTextMaxLines="1" />

        </lightning:card>  

    </aura:component>

    1. Click File > Save.
    2. Click CONTROLLER in the component palette on the right and replace the contents with this code:

    ({

       doInit : function(component, event, helper) {

          window.addEventListener("message", $A.getCallback(function(event) {

             if (event.data === 'reloadComponent') {

               helper.renderResults(component);

             }

          }), false);

          var rowActions = [{

             'label': 'Delete',

             'iconName': 'utility:delete',

             'name': 'delete'

          }];

          component.set("v.Columns", [

            {label:"Result Name", fieldName:"Name__c", type:"text", wrapText: true},

            {label:"Result Url", fieldName:"Result_Url__c", type:"url", wrapText: true},

            {label:"Source", fieldName:"Source__c", type:"text", wrapText: true},

            {label:"Author", fieldName:"Author__c", type:"text", wrapText: true},

            {type: 'action', typeAttributes: { rowActions: rowActions }}

          ]);

          helper.renderResults(component);

       },

       handleRowAction: function (cmp, event, helper) {

          var action = event.getParam('action');

          var row = event.getParam('row');

          switch (action.name) {

             case 'delete':

               helper.removeResult(cmp, row);

               break;

          }

       }

    })

    1. Click File > Save.
    2. Click HELPER in the component palette on the right and replace the contents with this code:

    ({

        renderResults: function(component) {        

          var action = component.get("c.getAttachedResults");

            if (action) {

                action.setParams({

                    recordId: component.get("v.recordId")

                });

                action.setCallback(this, function(response) {

                  var state = response.getState();

                  if (state === "SUCCESS") {

                     var data = response.getReturnValue();

                     component.set("v.AttachedResultsCount", data.length);

                     component.set("v.AttachedResults", data);

                  }

                });    

                $A.enqueueAction(action);  

            }

        },

        removeResult: function (cmp, row) {

            var action = cmp.get("c.removeAttachedResult");    

            if (action) {

             action.setParams({

                    recordId: cmp.get("v.recordId"),

                    name: row.Name__c

                });

                action.setCallback(this, function(response) {

                  var state = response.getState();

                  if (state === "SUCCESS") {

                    var rows = cmp.get('v.AttachedResults');

                    var rowIndex = rows.indexOf(row);

        

                    rows.splice(rowIndex, 1);

                    cmp.set('v.AttachedResults', rows);

                    cmp.set('v.AttachedResultsCount', rows.length);

                  }

                });

                $A.enqueueAction(action);  

            }

        }

    })

    1. Click File > Save.
    2. Click STYLE in the component palette on the right and replace the contents with this code:

    .THIS .tableHeader thead th button {

        visibility: hidden;

        display: none;

    }

    .THIS {

        margin-bottom: 10px;

    }

    .THIS div.slds-card__header {

        border-bottom: var(--lwc-borderWidthThin) solid var(--lwc-cardColorBorder);

        padding: 8px !important;

        background: var(--lwc-pageHeaderColorBackground,rgb(243, 242, 242));

    }

    .THIS div.slds-card__body {

        margin-top: -8px;                  

    }

    1. Click File > Save.
    2. Add the component to the Case page the same way as described in this section: Lightning App Builder to add components

    Step 4 Add a new custom action button: Attach to CasePermanent link for this heading

    In this step, the action button Attach To Case will be added to each search results. In addition, you will add the handler function which is fire when the action button is triggered.

    Please apply the following steps:

    1. In Salesforce, click the gear icon then select Setup.
    2. Search for and select Visualforce pages.
    3. Choose the existing VF page. (In our example, Mindbreeze_search_page)
    4. Click on Edit.
    5. In the Visualforce Markup:
      1. Add the extension AttachedResultController to the VF page.
        Code Before:
        <apex:page standardController="Case">

        Code After:
        <apex:page standardController="Case" extensions="AttachResultController">
    1. Add the Apex handler function:

      Code Before:
      <script>

         Mindbreeze.require(["client/application"], function(Application){

            var subject = "{! Case.Subject }";

            var App = Application.extend({

                prepareModels: function() {

                   this.setUnparsedUserQuery(subject);

                }

             });

             var application = new App();

         });

      </script>


      Code After:
      <script>
         Mindbreeze.require(["client/application"], function(Application){

            var subject = "{!
      Case.Subject }";
            var App = Application.extend({

                prepareModels: function() {

                   this.setUnparsedUserQuery(subject);

                }

             });

             var application = new App();

         });

      </script>


      <script>
          function handleAttachCaseAction(returnValue) {

              if (returnValue === "duplicate record") {

                 alert("This result is already attached to the current case: {!Case.CaseNumber}");

              } else if (returnValue === "reload component") {

                 var lexOrigin = 'https://<salesforce-page>.lightning.force.com';

                 parent.postMessage('reloadComponent', lexOrigin);

              }

          }

      </script>

      <apex:form >

            <apex:actionFunction name="AttachToCase" action="{!attachResultToCase}" oncomplete="handleAttachCaseAction('{!ValueReturned}')">

                <apex:param name="resultName" value="" />

                <apex:param name="resultUrl" value="" />

                <apex:param name="source" value="" />

                <apex:param name="author" value="" />

            </apex:actionFunction>

      </apex:form>
    1. Add the action button Attach To Case & attachResult handler function:

      Code Before:
      <script>
        Mindbreeze.require(["client/application”], function(Application) {

              var subject = "{! Case.Subject }";

              var App = Application.extend({

                    prepareModels: function() {

                        this.setUnparsedUserQuery(subject);

                    }

              });

              var application = new App();

           });

      </script>


      Code After:
      <script>
      Mindbreeze.require(["client/application"
      , "api/v2/api", "underscore"], function(Application, API, _) {
      var subject = "{! Case.Subject }";

      var App = Application.extend({

         prepareModels: function() {

          this.setUnparsedUserQuery(subject);

         }
      ,
         attachResult: function(options) {

           var model = options.model;

           var actions = model.get("actions");

           var resultName = model.get()["title"].data[0].value;

           var source = model.get('category') + '/' + model.get('categoryinstance');

           var author = model.get('Author') || 'N/A';

           var openAction = _.find(actions, function(action) {

              return action.id == "Open";

           });

           if(!openAction) {

             openAction = _.find(actions, function(action) {

               return action.href;

             });

           }

           if(openAction && openAction.href.length > 255) {

             openAction.href = 'Result URL is too long';

           }

           /* Passing result to controller */

           AttachToCase(resultName, openAction.href, source, author);

         }

      });

      var application = new App();

      API.search.on("loadoutput", function(model, atts, options) {
        if((atts && atts.resultset && atts.resultset.results) || (atts && atts.results)) {

         _.each((atts.resultset&&atts.resultset.results)||atts.results,function(result){      

           var actionName = "attachToCase";

           var htmlAction = "<a role=\"button\" data-action-name=\"attachResult\">Attach to Case</a>";

           result.properties.actions && result.properties.actions.data &&

           result.properties.actions.data.push({

              "html": htmlAction,

              "value": {

        
             "action":{ actionName:{} }
              }

           });

           result.properties.actions && result.properties.actions.properties &&

           result.properties.actions.properties.push({

              "id": actionName,

              "name": actionName,

              "data": [{

                "html": htmlAction,

                "value": {

                  "action":{ actionName: {} }
                }

              }]

           });

         });

        }

      });

      });

      </script>

    Click Save and return back to any Case page.

    In the search results, you will see the new custom action button:

    Click on the Attach To Case button and the search result will be displayed in a table view:

    TroubleshootingPermanent link for this heading

    Salesforce field limitationsPermanent link for this heading

    Example: Result URL field has a maximum length of 255 characters

    If a link is longer than 255 characters, an error occurs.

    Workaround: Display instead a string “Result Url is too long”

    How?

    In your VF page, at the Mindbreeze require <script> tag, at the attachResult function, add the following yellow highlighted code:

    <script>

    Mindbreeze.require(["client/application", "api/v2/api", "underscore"], function(Application, API, _) {

    var subject = "{! Case.Subject }";

    var App = Application.extend({

       prepareModels: function() {

        this.setUnparsedUserQuery(subject);

       },

       attachResult: function(options) {

         var model = options.model;

         var actions = model.get("actions");

         var filename = model.get()["title"].data[0].value;

         var source = model.get('category') + '/' + model.get('categoryinstance');

         var author = model.get('Author') || 'N/A';

         var openAction = _.find(actions, function(action) {

            return action.id == "Open";

         });

         if(!openAction) {

           openAction = _.find(actions, function(action) {

             return action.href;

           });

         }

         if(openAction && openAction.href.length > 255) {

        openAction.href = 'Result URL is too long';

         }        

         /* Passing result to controller */

         AttachToCase(filename, openAction.href, source, author);

       }

    });

    var application = new App();

    });

    </script>

    How to request search results properties from the Mindbreeze search modelPermanent link for this heading

    Example below requests the Author and extension properties:  

    First, in your Insight App snippet, add the following html:  

    <span style="display:none">{{Author}}{{extension}}</span>

    And then in the attach result function at the <script> tag:

    var author = model.get('Author') || 'N/A';

    var extension = model.get('extension');

    Clear button (x) in the search bar is not workingPermanent link for this heading

    In the browser console (F12), you see the following error:

    Uncaught SyntaxError: Unexpected token & in JSON at position 2

    Solution:

    In the VF page, in your html code snippet of your search app replace the following code:
    data-action-object="{&quot;resetSearch&quot;:{}}"

    with
    data-action-object='{"resetSearch":{}}'

  • Download PDF

    • Whitepaper - Mindbreeze InSpire Insight Apps in Salesforce

    Content

    • Table of Contents
    • Introduction
    • Software Prerequisites
    • Embedding an Insight App via Lightning Component
    • Embedding an Insight App via Visualforce Page
    • Lightning App Builder to add components
    • Use Case Set the case record Subject field as a search query in the VF search page
    • Use Case Attach search results to a case record
    • Troubleshooting

    Download PDF

    • Whitepaper - Mindbreeze InSpire Insight Apps in Salesforce