Navbar

MyInsights v2.0

Users who are upgrading from an older version of MyInsights need the following Javascript library Download Input File

See HTML Reports for more information.

The MyInsights library is dependent on the Q library which enables users to work with promises as returns from the MyInsights library methods. Include the Q library as a script in the custom report package.

Note: When requesting a Salesforce Field using a MyInsights method, the field must be case sensitive.

DataService

The DataService provides the primary interface for interacting with the Salesforce data. The DataService is a primary singleton instantiating itself upon execution of this script and is available in the global scope as ‘ds’, for example: 'window.ds’. The aim of the DataService is to simplify querying of Salesforce data from within your custom HTML-based application. The primary function of the DataService queries a set of records for you according to the config object you pass in. It provides a record set that is data-typed, properly labeled, with recordtype and picklist labels returned conveniently for you.

Methods

getDataForCurrentObject(object, field)

Request

/* This example comes from the Account Profile Override entrypoint*/

function start() {
    queryCRMData();
}



function queryCRMData() {
    ds.getDataForCurrentObject('Account', 'Credentials_vod__c').then(
        function(resp) {
            console.log(resp);
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}



function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

Response


{
   "Account":{
      "Credentials_vod__c":"DO"
   },
   "success":true
}

Returns the value of a field for a specific record related to the current object. This method does not support asynchronous calls. In order to successfully retrieve data at scale, the getDataForCurrentObject method must be called in sequence using the .then promise function.

Parameters:

Name Type Description
object string The API Name of the object you wish to query.
field string The API Name of the field for which you wish to retreive a value.

Returns:

The promise returned when resolved will return the results of the query.

Type

object

Keywords supported by entry point:

Order: Account, TSF, User, Order, HTMLReport
Account: Account, TSF, User, HTMLReport
Homepage: User, HTMLReport
Account Plan: AccountPlan, Account, User, HTMLReport
Inventory Monitoring: Account, TSF, User, InventoryMonitoring, HTMLReport

getFieldLabels(queryConfig)

Request

function start() {
    queryCRMData();
}



function queryCRMData() {
    var queryConfig = {
        object: "Clinical_Trial__c",
        fields: ["Name", "Display"],
    };

    ds.getFieldLabels(queryConfig).then(
        function(resp) {
            console.log(resp);
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}



function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

Response

{
  "Clinical_Trial__c":{
    "display":"Start Date",
    "name":"Start_Date_vod__c"
  }
}

Return the labels for the list of fields passed in.

Parameters:

Name Type Description
queryConfig object {object: String, fields: Array}

Properties

Name Type Description
object string Name of the object to query
fields array An array of field Labels to return.

Returns:

The promise returned when resolved will return the results of the query.

Type

promise

getInStatement(ids)

Request

ds.getInStatement(ids)

  // input looks like
  [idOne, idTwo, idThree]

Response

  // output format
  ('idOne','idTwo','idThree')
    //or
  {'idOne','idTwo','idThree'}
  //depends on the online version or not

Generate an 'IN’ statement for the where clause of a query.

Parameters:

Name Type Description
ids array An array of ids to use in the 'IN’ statement.

Returns:

A string 'IN’ statement for including in the 'WHERE’ statement of query.

Type

string

getObjectLabels(object)

Returns the labels for the list of object names passed in.

Request

    function start() {
        queryCRMData();
    }

    function queryCRMData() {
        var queryConfig = ["Medical_Event_vod__c"]

        ds.getObjectLabels(queryConfig).then(
            function(resp) {
                console.log(resp);
                printToScreen(resp);
            },
            function(err) {
                console.log(err);
            }
        );
    }

    function printToScreen(jsonObj) {
        var test = document.getElementById("test");
        test.innerHTML = JSON.stringify(jsonObj);
    }

    document.addEventListener("DOMContentLoaded", function(event) {
        start();
    });

Response

{
   "success":true,
   "Medical_Event_vod__c":[
      {
         "plural":"Medical Events",
         "singular":"Medical Event"
      }
   ]
}

Parameters:

Name Type Description
object array A list of object names for which to retrieve labels.

Returns:

The promise returned when resolved will return the results of the query.

Type

object

getPicklistValueLabels(object, field)

Request

ds.getPicklistValueLabels(object, field){

  "Account" (which is object),  "Career_Status_vod__c" (which is field)

Response

{
  "Account":{
    "Career_Status_vod__c":
      {
        "Emerging_vod": "Emerging",
        "Peak_vod": "Peak",
        "Retired_vod": "Retired"
      }
    },

  "command": "queryReturn",
  "deferredId": "callback_1482531900000"
}

The getPicklistValueLabels returns the translated label for each of the picklist values of the specified field.

Parameters:

Name Type Description
object string The API Name of the object you wish to query.
field string API Name of the picklist field.

Returns:

The promise returned when resolved will return the results of the query.

Type

promise

getVeevaMessagesWithDefault(tokens, localeKey)

Request


    function start() {
            queryCRMData();
        }



    function queryCRMData() {
        var tokens = [
            { msgCategory:"Common", msgName:"UPCOMING"},
        ]

        var languageLocaleKey = "en_US";

            ds.getVeevaMessagesWithDefault(tokens,languageLocaleKey).then(function(resp){
                console.log(resp);
                printToScreen(resp);
                }, function(err) {
                    console.log(err);
                printToScreen(err);

                }
                );
    }




    function printToScreen(jsonObj) {
        var test = document.getElementById("test");
        test.innerHTML = JSON.stringify(jsonObj);
    }

    document.addEventListener("DOMContentLoaded", function(event) {
        start();
    });

Response

[
   {
      "Language_vod__c":{
         "value":"en_US",
         "display":"en_US",
         "dataType":"string",
         "label":"Language"
      },
      "Name":{
         "value":"UPCOMING",
         "display":"UPCOMING",
         "dataType":"string",
         "label":"Message Name"
      },
      "Text_vod__c":{
         "value":"Upcoming",
         "display":"Upcoming",
         "dataType":"string",
         "label":"Text"
      },
      "Category_vod__c":{
         "value":"Common",
         "display":"Common",
         "dataType":"string",
         "label":"Category"
      }
   }
]

The getVeevaMessagesWithDefault method returns the translated value of each of the tokens passed in to the language specified by the localeKey. The tokens must be case sensitive and exactly match the Salesforce record.

Parameters:

Name Type Description
tokens array A list of string tokens to be translated.
localeKey string The name of the locale.

Returns:

The promise returned when resolved will return the results of the query.

Type

object

joinQueries(q1, q2, keyForID, fieldsLabelsToExclude, primaryObjectName)

Request

// Input
var q1 = {
    data: [{
        ID: {
            value: "abc",
            display: "abc",
            dataType: "string",
            label: "Record ID"
        },
        Name: {
            value: "productA",
            display: "product A",
            dataType: "string",
            label: "Product Name"
        }
    }],
    object: {
        plural: "Product Catalog",
        singular: "Product Catalog",
        name: "Product_vod__c"
    },
    name: "Product_vod__c",
    fieldLabels: [{
        name: "ID",
        display: "Record ID"
    }, {
        name: "Name",
        display: "Product Name"
    }]
};

var q2 = {
    data: [{
        ID: {
            value: "1234",
            display: "1234",
            dataType: "string",
            label: "Record ID"
        },
        Product_vod__c: {
            value: "abc",
            display: "abc",
            dataType: "string",
            label: "Product"
        }
    }],
    object: {
        plural: "Sent Email",
        singular: "Sent Email",
        name: "Sent_Email_vod__c"
    },
    name: "Sent_Email_vod__c",
    fieldLabels: [{
        name: "ID",
        display: "Record ID"
    }, {
        name: "Product_vod__c",
        display: "Product"
    }]
};

var keyForID = 'Product_vod__c';

var fieldsLabelsToExclude = {
    ID: true,
    Product_vod__c: true
};

var primaryObjectName = 'Sent_Email_vod__c';
//input format

Response

{
  data: [
    {
      ID: {
        value: "1234",
        display: "1234",
        dataType: "string",
        label: "Record ID"
      },
      Product_vod__c: {
        value: "abc",
        display: "abc",
        dataType: "string",
        label: "Product"
      },
      Product_vod__c.ID: {
        value: "abc",
        display: "abc",
        dataType: "string",
        label: "Record ID"
      },
      Product_vod__c.Name: {
        value: "productA",
        display: "product A",
        dataType: "string",
        label: "Product Name"
      }
    }
  ],

  fieldLabels: [
    {
      name: "Product_vod__c.Name",
      display: "Product Name"
    }
  ],

  name: 'Sent_Email_vod__c',
  object: {
    plural: "Sent Email",
    singular: "Sent Email",
    name: "Sent_Email_vod__c"
  }
}

Join two queries similarly to an SQL outer join.

Parameters:

Name Type Description
q1 object One of the query responses that needs to be joined.
q2 object One of the query responses that needs to be joined.
keyForID string The field name inside the primary query response in which the query response joins based on the ID value.
fieldsLabelsToExclude object A map that contains the API names to exclude from the join result’s field labels.
primaryObjectName string The name of the object to indicate the primary query response between q1 and q2.

Returns:

A new object containing the joined queries as a single result set.

Type

object

runQuery(queryConfig)

Request

function start() {
    queryCRMData();
}



function queryCRMData() {
    var queryConfig = {
        object: "Account",
        fields: ["Name"],
        where: "",
        sort: [],
        limit: "1"
    };

    ds.runQuery(queryConfig).then(
        function(resp) {
            console.log(resp);
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}



function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});


Response


{
   "data":[
      {
         "Name":{
            "value":"Morris Area Integrated Phys, Ipa",
            "display":"Morris Area Integrated Phys, Ipa",
            "dataType":"string",
            "label":"Name"
         }
      }
   ],
   "object":{
      "plural":"Accounts",
      "singular":"Account",
      "name":"Account"
   },
   "name":"Account",
   "fieldLabels":[
      {
         "name":"Name",
         "display":"Name"
      }
   ]
}

Run a query.

Parameters:

Name Type Description
queryConfig object {object: String, fields: array, where: String, sort: array, limit: String}

Properties

Name Type Description
object string API name of the object to query.
fields array of strings An array of field API Names to return.
where string The where statement without the “where” string. ex: where: “Name = 'Accessing My Insights’”
sort array An array of sort statements without the “order by” string. ex: sort: ['LastModifiedDate DESC’]
limit string The maximum number of records to return.

Returns:

When resolved, the promise will return the results of the query.

Type

Promise resolves to an object

runQuery(SalesData)

Run a query for Sales Data.

Ensure your administrator deactivates the Contains Goals and Payer Plan Mapped fields, and adds unique column labels on the Data Map Template before configuring, uploading, and syncing the sales data files. This ensures that the appropriate account level sales data is retrieved.

Request


function start() {
    queryCRMData();
}

function queryCRMData() {
    var queryConfig = {
        object: "Account_Sales_Summary_Insights",
        fields: ["Account_Id_vod", "Market_vod", "Product_Group_vod"],
        where: "'scale = 'week_vod' AND 'dataType' ='NRx' AND AccountId in {'id1', 'id2', 'id3']",
        sort: [],
        limit: "1"
    };

    ds.runQuery(queryConfig).then(
        function(resp) {
            console.log(resp);
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}

function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

Response

{
  "Account_Sales_Summary_Insights": [
    {
      "Account_Id_vod": {
        "value": "a00i0000001F4tMAAS",
        "display": "a00i0000001F4tMAAS",
        "dataType": "string",
        "label": "Account Sales Summary Insights"
      },
      "Market_vod": {
        "value": "Cardiology",
        "display": "Cardiology",
        "dataType": "string",
        "label": "Account Sales Summary Insights"
      }
    },
    {
      "Product_Group_vod": {
        "value": "Cholecap 10mg",
        "display": "Cholecap 10mg",
        "dataType": "string",
        "label": "Account Sales Data Insights"
      },
      "Sales_Date_vod": {
        "value": "201705",
        "display": "201705",
        "dataType": "string",
        "label": "Account Sales Summary Insights"
      },
      "Sales_Data_vod": {
        "value": "101",
        "display": "101",
        "dataType": "string",
        "label": "Account Sales Summary Insights"
      }
    },
    "fieldLabels": [
      {
        "name": "Product_Group_vod",
        "display": "Product Group"
      },
      {
        "name": "Market_vod",
        "display": "Market"
      },
    ],
    "name": "Account_Sales_Summary_Insights",
    "object": {
      "plural": "Account Sales Summary Insights'",
      "singular": "Account Sales Summary Insights",
      "name": "Account_Sales_Summary_Insights_vod"
    }
  ]
}

Object

Name Description
Account_Sales_Summary_Insights Represents the object that contains the Account-level Sales Data.

Where Clause Parameters:

Name Values Description
Scale

required

week_vod or month_vod Defines the time frame that the sales data is aggregated.
DataType

required

TRx or NRx Locates the sales data. Sales data is organized using columns. Column_Label_vod for instance being NRx. However, if the Column_Label_vod is changed to any other value, the datatype query also changes.
Account_ID_vod

required

AccountId Represents the Account ID_vod that links the Account to the Account Object.
Start Date

optional

yyyy-MM-dd Represents the Start Date of the period to query.
End Date

optional

yyyy-MM-dd Represents the End Date of the period to query.
Market Products

optional

Market_vod Represents the Market that the products are grouped. These groups can be queried using their SFDC IDs.
Product Group

optional

Product_Group_vod Represents the Product Name. This can be queried using the SFDC IDs.

Where Clause Requirements:

Fields (Included, but are not limited to) :

Name API Name
Account ID Account_ID_vod__c
ID ID_vod__c
Market Market_vod__c
Market Salesforce ID Market_Id_vod__c
Product Group Product_Group_vod__c
Product Group Salesforce ID Product_Group_Id_vod__c

Additional fields can be found in the Data_Map_Template_vod and the Sales_Transaction_vod objects.

Output

When the object Account_Sales_Summary_Insights is queried, the system identfies the Sales Data based on the parameters of the where clause. In this instance, the where clause uses Weeks as a scale, NRx as a dataType and id1, id2 and id3 as the Account ID.

The system uses the Data Map Template and the corresponding Analytics File to query the Sales Data table using the Where Clause as a filter.

Note

querySalesData(queryConfig)

The querySalesdata method returns a promise that is resolved with that single record. This method can only query Account_Sales_Summary_Insights_vod.

Ensure your administrator deactivates the Contains Goals and Payer Plan Mapped fields, and adds unique column labels on the Data Map Template before configuring, uploading, and syncing the sales data files. This ensures that the appropriate account level sales data is retrieved.

The default list of fields returned if user does not specify any fields in the request is: Account_Id_vod__c, ID_vod__c, Market_vod__c, Market_Id_vod__c, Product_Group_vod__c, Product_Group_Id_vod__c, Sales_Date_vod__c, Sales_Data_vod__c.

Request

function start() {
    queryCRMData();
}

function queryCRMData() {
    var queryConfig = {
        object: "Account_Sales_Summary_Insights",
        fields: ["Account_Id_vod__c", "Market_vod__c", "Market_ID_vod__c", "Product_Group_vod__c", "Product_Group_Id_vod__c", "Sales_Date_vod__c", "Sales_Data_vod__c"],
        where: "",
        sort: [],
        limit: "3"
    };

    ds.querySalesData(queryConfig).then(
        function(resp) {
            console.log(resp);
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}

function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

Response

{
  "success": "true",
  "record_count": "2",
  "Account_Sales_Summary_Insights": [
    {
      "Account_Id_vod__c": "0013600000ILOftAAH",
      "Market_Id_vod__c": "a0u3600000116RtAAI",
      "Market_vod__c": "Mkt1Lvl",
      "Product_Group_Id_vod__c": "a0l36000000vV0bAAE",
      "Product_Group_vod__c": "Mkt1Lvl-CompetitorProduct_5-NoBDL",
      "Sales_Date_vod__c": "2016-06-01",
      "Sales_Data_vod__c": "834.042"
    },
    {
      "Account_Id_vod__c": "0013600000ILOftAAH",
      "Market_Id_vod__c": "a0u3600000116RtAAI",
      "Market_vod__c": "Mkt1Lvl",
      "Product_Group_Id_vod__c": "a0l36000000vV0bAAE",
      "Product_Group_vod__c": "Mkt1Lvl-CompetitorProduct_5-NoBDL",
      "Sales_Date_vod__c": "2017-05-01",
      "Sales_Data_vod__c": "908.053"
    }
  ]
}

Parameters:

Name Type Description
queryConfig object {object: String, fields: array, where: String, sort: array, limit: String}

Properties

Name Type Description
object string Name of the object to query
fields array An array of field API Names to return
sort array The sort statement without the “order by” string. ex: sort: ['Call_Date_vod__c DESC’]
where string The where statement without the “where” string. ex: where: “Name = 'Accessing MyInsights’”
limit number The maximum number of records to return

Returns:

The promise returned when resolved returns the results of the query.

Type

promise

queryRecord (queryConfig)

The queryRecord returns a promise that is resolved with that single record. This method returns the rawdata as key value pairs without adding additional metadata (e.x., object labels, field labels etc.) in the returned results.

Request

function start() {
    queryCRMData();
}



function queryCRMData() {
    var queryConfig = {
        object: "Account",
        fields: ["Name", "Phone", "Fax"],
        where: "",
        sort: [],
        limit: "3"
    };

    ds.queryRecord(queryConfig).then(
        function(resp) {
            console.log(resp);
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}



function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

Response

{
   "Account":[
      {
         "Phone":"(973) 586-3400",
         "Name":"Morris Area Integrated Phys, Ipa",
         "Fax":""
      },
      {
         "Phone":"",
         "Name":"Deborah Farabee",
         "Fax":""
      },
      {
         "Phone":"",
         "Name":"Virginia Krieg",
         "Fax":""
      }
   ],
   "success":true,
   "record_count":3
}

Parameters:

Name Type Description
queryConfig object {object: String, fields: array, where: String, sort: array, limit: String}

Properties

Name Type Description
object string API Name of the object to query
fields array of strings An array of field API Names to return
where string The where statement without the “where” string. ex: where: “Name = 'Accessing MyInsights’”
sort array of strings The sort statement without the “order by” string. ex: sort: ['Call_Date_vod__c DESC’]
limit number The maximum number of records to return

Returns:

When resolved, the promise will return the results of the query.

Type

Promise resolves to an object

newRecord(configObject)

The newRecord method displays the native interface of the object within Veeva CRM.

HTML


  <button id="demo" onclick="queryCRMData()"> Launch Call </button>

Request


function start() {
    queryCRMData();
}


function queryCRMData() {
    var configObject = {
        object: "Call2_vod__c",
        fields: {
            Account_vod__c: "00161000004vuXMAAY"
        }
    };

    ds.newRecord(configObject).then(
        function(resp) {
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}



function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

As a useful tip, developers can leverage the getDataForCurrentObject method to pass in the Account ID, ds.getDataForCurrentObject('Account’).

Parameters:

Name Type Description
configObject object A configuration object used to pass in required values

Properties

Name Type Description
object string API name of the target object
fields array of strings Object of field API names required to pass in for the application to bring up specified action

Returns:

When the request is successful, the application displays the native interface

viewRecord(configObject)

The viewRecord method navigates to the detail page in Veeva CRM.

When users open the detail page, they can navigate back to their MyInsights report by selecting back, returning to their last viewed screed.

When navigating to MyInsights reports for the first time, the last modified report displays.

HTML


  <button id="demo" onclick="queryCRMData()"> Launch Call </button>

Request

     function start() {
            queryCRMData();
        }

    function queryCRMData() {
        var configObject = {
            object: "Call2_vod__c",
            fields: {Id: "a040U000000UJPUQA4"} 
        };

                ds.viewRecord(configObject).then(
            function (resp) {
                 printToScreen(resp);
                }, function(err) {
                    console.log(err);
                }
                );
    }



    function printToScreen(jsonObj) {
        var test = document.getElementById("test");
        test.innerHTML = JSON.stringify(jsonObj);
    }

    document.addEventListener("DOMContentLoaded", function(event) {
        start();
    });

Parameters:

Name Type Description
configObject object A configuration object used to pass in required values

Properties

Name Type Description
object string API name of the target object
fields array of strings Object of field API names required to pass in for the application to bring up specified action

Returns:

When the request is successful, the application displays the native interface

getAvailableObjects()

This method retrieves a list of objects for which the user has Read permissions to in their org.

Request

function start() {
    queryCRMData();
}



function queryCRMData() {


    ds.getAvailableObjects().then(
        function(resp) {
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}



function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

Response

{
   "success":true,
   "data":{
      "Sample_Lot_vod__c":{

      },
      "User":{

      },
      "Assortment_vod__c":{

      },
      "Event_Attendee_vod__c":{

      }
   },
   "record_count":0
}

Parameters:

The default behavior of the method returns a full list of available objects.

Returns:

When the request is successful, the application displays a list of available end-user objects

getObjectMetadata(configObject)

The getObjectMetadata method retrieves the list of fields the user has Read permissions to in a specific object.

Request

function start() {
    queryCRMData();
}



function queryCRMData() {
    var configObject = {
        object: "Account",
    };

    ds.getObjectMetadata(configObject).then(
        function(resp) {
            printToScreen(resp);
        },
        function(err) {
            console.log(err);
        }
    );
}



function printToScreen(jsonObj) {
    var test = document.getElementById("test");
    test.innerHTML = JSON.stringify(jsonObj);
}

document.addEventListener("DOMContentLoaded", function(event) {
    start();
});

Response

{
   "success":true,
   "data":{
      "object":"Account",
      "fields":[
         {
            "name":"AHA__c",
            "dataType":"string"
         },
         {
            "name":"AccountSource",
            "dataType":"picklist"
         },
         {
            "name":"Total_Physicians_Enrolled__c",
            "dataType":"double"
         },
         {
            "name":"Total_Revenue_000__c",
            "dataType":"currency"
         },
         {
            "name":"Website",
            "dataType":"url"
         }
      ]
   },
   "record_count":153
}

Parameters:

Name Type Description
configObject object {object: string}

Properties

Name Type Description
object string API name of the target object

Returns:

When the request is successful, the Object API Name, Field API Name and the field type of the Field displays.

getRecordTypeLabels()

The getRecordTypeLabels method returns the record type’s API name and record type translated label.

Request


var objectName = "Account";

ds.getRecordTypeLabels(objectName).then(
  function(response){
     console.log(response);//example of logging the response
    },
  function(error){
      console.log(error);//example of logging the error 
    }
);

Response

{ 
    "Account":{
      "recordtype_name1":"recordtype_label1", 
      "recordtype_name2":"recordtype_label2"
    }
}

Parameters:

Name Type Description
objectName string API name of the target object

Returns:

When the request is successful, the record type’s API name and record type displays.

executeSuggestionAction(SuggestionId,actionType)

The executeSuggestionAction method enables the execution, completion, and dismissal of suggestions.

Example

ds.executeSuggestionAction(suggestionId, actionType).then(function(resp) {
  // success callback
  if(resp && resp.success) {
    // The operation is completed. The following is an example of refreshing the UI after success:
    ds.queryRecord({
      object: "Suggestion_vod__c",
      fields: ["Title_vod__c", "RecordTypeId", "Posted_Date_vod__c"],
      where: "Account_vod__c = _accountId"
    }).then(function(resp) {
      // Update UI with lastest suggestion response
      });
  } else {
    // The operation is cancelled
  }
}, function(error) {
  // The operation was interrupted due to an internal error 
});

Parameters:

Name Type Description
SuggestionId string 18-character SFDC ID of the Suggestion record
actionType string Supports the following values:
  • complete - Marks the suggestion as complete
  • dismiss - Dismisses the suggestion
  • execute - The default action, if left blank. Executes the suggestion based on the Suggestion Type. Supported Types are:
    • Call_Objective_vod
    • Call2_vod
    • Email_vod

Arrays of Suggestions

The SuggestionId parameter may also be an array of 18-character SFDC ID strings, enabling the execution of multiple suggestions at once. When passing an array of strings, the actionType parameter MUST be left blank.

Returns:

When the request is successful, the desired action is made against the specified suggestion.

The list of suggestions displayed to the user should be active suggestions that have not yet been dismissed, executed, or marked as complete.

launchMediaForAccount(account, presentationId, keyMessageMediaFileName)

The launchMediaForAccount method enables launching a CLM presentation directly from a visualization and, optionally, have that presentation open to a specific Key Message.

Launching a CLM Presentation to a Specific Slide

ds.launchMediaForAccount("acct","MyPresentation","HomePage");
//Launches the CLM presentation with a Presentation_Id_vod field of "MyPresentation"
//and goes directly to the Key Message in that presentation with a Media_File_Name_vod of "HomePage".
//The presentation is logged against the Account with an SFC ID of "acct".

Launching the CLM Library

ds.launchMediaForAccount("acct");
//Navigates to the CLM library to select the appropriate CLM presentation.
//The presentation is logged against the Account with an SFDC ID of "acct".

Parameters:

Name Type Description
account string ID of the Account
presentationId string Enter the Presentation_Id_vod field of the CLM_Presentation_vod record you want to launch
keyMessageMediaFileName string Enter the Media_File_Name_vod field of the Key_Message_vod record to directly open

Returns:

When the request is successful, the specified CLM presentation displays. If the keyMessageMediaFileName parameter is populated with a valid Key Message, the presentation opens directly to that Key Message.

If the presentationId and keyMessageMediaFileName parameters are blank, a successful request displays the CLM Library instead, enabling users to select the presentation to display.