Multichannel CRM
Veeva publishes a JavaScript library to assist customers and their creative agencies with developing personalized and dynamic HTML5 content that interacts with the Veeva CRM database. This library is supported for CLM, Engage for Portals, CoBrowse, and MyInsights content creation.
Engage for Portals and CoBrowse have limitations described in the content creation guidelines.
Click here for the download file.
Beginning with CRM release 17R1, MyInsights content development should use the MyInsights v2.0 Javascript Library.
Namespace: clm
The com.veeva.clm namespace should be utilized when calling the JavaScript functions. Example: "com.veeva.clm.getDataForCurrentObject("Account","ID", myAccountID);"
The JavaScript library returns in the following format:
- {success:true, obj_name:[{"Id":"0001929312"}, , ...]} or
- {success:false, code:####, message:"message_text"}
The following denotes the specific error code (1000 is from the underlying API, 2000 is from the JavaScript library):
- 2000 - Callback function is missing
- 2001 - Callback is not a JavaScript function
- 2002 - is empty
- 2100 - Request (%@) failed: %@
- message_text - begins with the JavaScript library function name and a ":". If the error comes from the underlying API, the full message from the API is appended to the message_text
For CLM: With the exception of gotoSlide, the JavaScript functions respect My Setup, Restricted Products on Account, Allowed Products on Call and on TSF. Only company products are returned. goToSlide respects all of the above when media is launched from a Call or an Account. goToSlide does not respect Restricted Products and Allowed Products when media is launched from the home page.
Use the JavaScript functions in a chain, i.e. call the second JavaScript function only in the first function's callback function or after the callback of the first function is finished. Because the underlying API calls are asynchronous, this may result in unexpected return values if the JavaScript functions are not properly chained.
Veeva recommends caution when retrieving/saving data using the following field types and to always perform rigorous testing:
- Long Text Area
- Rich Text Area
- Encrypted Text Area
Classes
initialize
Methods
getAddresses_Account(account, callback)
//get the SFDCId of the current Account
function getCurrentAccountId() {
com.veeva.clm.getDataForCurrentObject("Account","Id",getAddressesForAccount);
}
//use the current Account Id to fetch the id's of all related Addresses
function getAddressesForAccount(result) {
if (result.success == true) {
com.veeva.clm.getAddresses_Account(result.Account.Id, displayAddressIds);
}
}
//return type is an array of record id's
function displayAddressIds(result) {
if (result.success == true) {
alert(JSON.stringify(result.Address_vod__c[0].Id)); //a01Z000000OdSjAIAV
alert(JSON.stringify(result.Address_vod__c[1].Id)); //a01Z000000c5ANu
}
}
Returns an array of record IDs of all addresses (Address_vod__c)
for a particular account (Account)
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
account
|
string | Specifies the record ID of the account of which to get all related addresses. |
callback
|
function | Call back function which is used to return the information. |
Returns
Like * {success:true, obj_name:[{"Id":"0001929312"}, , ...]} * {success:false, code:####, message:"message_text"}
Type
object
getAddressFields(record, fields, callback)
//assume 'addressId' references a valid SFDC Id of a record from the ``Address_vod__c`` object
function getCityStateZip() {
com.veeva.clm.getAddressFields(addressId, ["City_vod__c","State_vod__c","Zip_vod__c"], displayCityStateZip);
}
//return type is a JSON object (Address_vod__c) containing an array of length 1
function displayCityStateZip(result){
if (result.success == true) {
alert(JSON.stringify(result.Address_vod__c[0].City_vod__c)); //Columbus
alert(JSON.stringify(result.Address_vod__c[0].State_vod__c)); //OH
alert(JSON.stringify(result.Address_vod__c[0].Zip_vod__c)); //43210
}
}
Returns the values of the specified fields for specified Address (Address_vod__c)
record.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
record
|
string | Specifies the record ID of the Address to get fields from. |
fields
|
array | List of field api names to return a value for; this parameter should be an array. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getProduct_MySetup(type, callback)
//get all records aligned to the current user's MySetup where Product Type = 'Detail'
function getDetailProducts() {
com.veeva.clm.getProduct_MySetup("Detail", displayProductIds);
}
//return type is an array of record Id's from Product_vod__c
function displayProductIds(result) {
if (result.success == true && result.record_count > 0) {
alert(JSON.stringify(result.Product_vod__c));
}
}
Returns an array of record IDs of all products (Product_vod__c)
of a specified type that the User has access to.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
type
|
string | Specifies the Product Type (Product_Type_vod__c field on Product_vod__c ). |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getRecordType_Object(object, callback)
//get all recordtype id's for the Call object
function getCallRecordTypeIds () {
com.veeva.clm.getRecordType_Object("Call2_vod__c", displayRecordTypeIds);
}
//return type is an array of record id's from the RecordType object
function displayRecordTypeIds (result) {
if (result.success == true) {
alert(JSON.stringify(result.RecordType));
}
}
Returns an array of record IDs of all RecordType records (RecordType) for a particular object.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | Specifies the API name of the object of which to get all active RecordTypes. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getSurveyQuestions_Survey(survey, callback)
//Retrieves the Survey_vod__c lookup, which is the Survey Record ID
function getSurveyID(){
com.veeva.clm.getDataForCurrentObject("Presentation", "Survey_vod__c", getSurveyQs);
}
//Uses the Survey Record ID from above to retrieve all the Survey Question
// Record IDs of the for the Survey
function getSurveyQs(result){
com.veeva.clm.getSurveyQuestions_Survey(result.Presentation.Survey_vod__c, mySurveyQuestions);
}
//Displays the result from above to the HTML element named “returned_result”
function mySurveyQuestions(result){
divEle = document.getElementById("returned_result");
divEle.innerHTML += "<br/>" + (JSON.stringify(result));
}
Returns an array of record IDs of all Survey Questions (Survey_Question_vod__c)
for a specific Survey (Survey_vod__c)
.
Results are returned in ascending order based on the Order_vod__c
field on Survey Question_vod__c
.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
survey
|
string | Specifies the record ID of the Survey to get all related Survey Questions from |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getQuestionResponse_SurveyTarget(surveyTarget, callback)
//first, get the current Account Id, store it in a global scope variable called "AccId"
function getCurrentAccount() {
com.veeva.clm.getDataForCurrentObject("Account","Id",)
}
//Veeva data model assumes that a Survey will be assigned to a specific CLM Presentation record via a lookup relationship. If this function is being used for MyInsights, a custom lookup relationship from Survey to HTML Report is recommended,
function getRelatedSurveyId (result) {
if (result.success == true) {
AccId = result.Account.Id;
com.veeva.clm.getDataForCurrentObject("Presentation","Survey_vod__c",getSurveyTargets);
}
}
function getSurveyTargets(result) {
if (result.success == true) {
com.veeva.clm.getSurveyTarget_Account(AccId, result.Presentation.Survey_vod__c, getQRs);
}
}
//return type is an array of record ids from the Survey Target object. Use one to query for all related Question Responses
function getQRs(resut) {
if (result.success == true) {
com.veeva.clm.getQuestionResponse_SurveyTarget(result.Survey_Target_vod__c[0].Id, displayQRs);
}
}
//return type is an array of record ids from the Question Response object
function displayQRs(result) {
if (result.success == true) {
alert(JSON.stringify(result.Question_Response_vod__c));
}
}
Returns an array of record IDs of all Questions Responses (Question_Response_vod__c)
for a specific Survey
Target (Survey_Target_vod__c)
. Results are returned in ascending order based on the Order_vod__c
field on Question_Response_vod__c
.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
surveyTarget
|
string | Specifies the record ID of the Survey Target to get all related Question Responses from |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getSurveyTarget_Account(account, survey, callback)
//first, get the current Account Id, store it in a global scope variable called "AccId"
function getCurrentAccount() {
com.veeva.clm.getDataForCurrentObject("Account","Id",getRelatedSurveyId);
}
//Veeva data model assumes that a Survey will be assigned to a specific CLM Presentation record via a lookup relationship. If this function is being used for MyInsights, a custom lookup relationship from Survey to HTML Report is recommended,
function getRelatedSurveyId (result) {
if (result.success == true) {
AccId = result.Account.Id;
com.veeva.clm.getDataForCurrentObject("Presentation","Survey_vod__c",getSurveyTargets);
}
}
function getSurveyTargets(result) {
if (result.success == true) {
com.veeva.clm.getSurveyTarget_Account(AccId, result.Presentation.Survey_vod__c, displaySurveyTargetIds);
}
}
//return type is an array of record ids from the Survey Target object
function displaySurveyTargetIds(resut) {
if (result.success == true) {
alert(JSON.stringify(result.Survey_Target_vod__c));
}
}
Returns an array of record IDs of all Survey Targets (Survey_Target_vod__c)
for a specific account (Account) and a specific Survey (Survey_vod__c)
.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
account
|
string | Specifies the record ID of the Account to get all related Survey Targets from. |
survey
|
string | Specifies the record ID of the Survey to get all related Survey Targets from. Can be made optional by putting in "". |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getProduct_OrderActive_Account(accountOrAccountGroup, callback)
//first, get the current Account Id
function getCurrentAccount() {
com.veeva.clm.getDataForCurrentObject("Account","Id",getRelatedSurveyId);
}
//use the account id to get the related Products that have a valid list price for this specific Account
function getRelatedOrderProduct(result) {
if (result.success == true) {
com.veeva.clm.getProduct_OrderActive_Account(result.Account.Id, displayProductIds);
}
}
//return type is an array of record id's from the Product_vod__c object where Product Type = 'Order'
function displayProductIds(result) {
if (result.success == true) {
alert(JSON.stringify(result.Product_vod__c));
}
}
Campaign and Contract based Pricing Rules are not supported by the JavaScript Library for CLM Order Management functions.
Returns an array of record IDs of all products (Product_vod__c)
of type Order that have valid list prices.
Valid list price = Pricing Rule (Pricing_Rule_vod__c)
of record type List Price (List_Price_Rule_vod) where current date is between Start Date (Start_Date_vod__c)
and End Date (End_Date_vod__c)
.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
accountOrAccountGroup
|
string | Specifies the record ID of an Account or the matching text for the Account Group. Can be made optional by putting in "". When utilized, returns an array of record IDs of all products (Product_vod__c) of type Order that have valid list price records which specify the Account or Account Group. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getProduct_KitComponents(product, callback)
//first, get a Detail Product record Id
//get all records aligned to the current user's MySetup where Product Type = 'Detail'
function getDetailProducts() {
com.veeva.clm.getProduct_MySetup("Detail", getKitComponentProducts);
}
//for the sake of this example, the first product returned will be used
function getKitComponentProducts(result) {
if (result.success == true) {
com.veeva.clm.getProduct_KitComponents(result.Product_vod__c[0].Id, displayKitComponentProductsIds);
}
}
//return type is an array of record id's from the Product_vod__c object where Product Type = 'Kit Component'
function displayKitComponentProductsIds(result) {
if (result.success == true) {
alert(JSON.stringify(result.Product_vod__c));
}
}
Returns an array of record IDs of all products (Product_vod__c)
of type Kit Component (Product_Type_vod__c field)
who have parent product (Parent_Product_vod__c)
f = product.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
product
|
string | Specifies the record ID of the product of which to get all related Kit Components from. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getProductGroup_Product(product, callback)
//first get a Detail Prouct record Id
//get all records aligned to the current user's MySetup where Product Type = 'Detail'
function getDetailProducts() {
com.veeva.clm.getProduct_MySetup("Detail", getRelatedProductGroups);
}
//for the sake of this example, the first product returned will be used
function getRelatedProductGroups(result) {
if (result.success == true) {
com.veeva.clm.getProductGroup_Product(result.Product_vod__c[0].Id, displayRelatedProductGroups);
}
}
//return type is a array of record id's from the Product_Group_vod__c
function displayRelatedProductGroups(result) {
if (result.successs == true) {
alert(JSON.stringify(result.Product_Group_vod__c));
}
}
Returns an array of record IDs of Product Groups (Product_Group_vod__c)
the specified product (Product_vod__c)
is part of.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
product
|
string | Specifies the record ID of the product of which to get all related Product Groups from. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getLastTenOrders_Account(account, callback)
//first get the record id of a current Account
function getCurrentAccountId() {
com.veeva.clm.getDataForCurrentObject("Account","Id", getRelatedOrders);
}
function getRelatedOrders(result) {
if (result.success == true) {
com.veeva.clm.getLastTenOrders_Account(result.Account.Id, displayRelatedOrders);
}
}
//return type is an array of record id's from the Order_vod__c object
function displayRelatedOrders(result) {
if (result.success == true) {
alert(JSON.stringify(result.Order_vod__c));
}
}
Returns an array of record IDs of the last 10 Orders (Order_vod__c)
for a particular account (Account)
The order of last ten orders is based on the field Order_Date_vod__c
, descending.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
account
|
string | Specifies the record ID of the account of which to get all related orders. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getOrderLines_Order(order, callback)
//first get the record id of a current Account
function getCurrentAccountId() {
com.veeva.clm.getDataForCurrentObject("Account","Id", getRelatedOrders);
}
function getRelatedOrders(result) {
if (result.success == true) {
com.veeva.clm.getLastTenOrders_Account(result.Account.Id, getRelatedOrderLines);
}
}
//for the sake of this example, only the first order will be used
function getRelatedOrderLines(result) {
if (result.success == true) {
com.veeva.clm.getOrderLines_Order(result.Order_vod__c[0].Id, displayOrderLines);
}
}
//return type is an array of record Id's from the Order_Line_vod__c object
function displayOrderLines(result) {
if (result.success == true) {
alert(JSON.stringify(result.Order_Line_vod__c));
}
}
Returns an array of record IDs of all Order Lines (Order_Line_vod__c)
for a particular order (Order_vod__c)
.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
order
|
string | Specifies the record ID of the order of which to get all related order lines. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getListPrice_Product(product, callback)
Returns an array of record IDs for the currently valid List Price (Pricing_Rule_vod__c)
for a specific product (Product_vod__c)
Valid list price = Pricing Rule (Pricing_Rule_vod__c)
of record type List Price (List_Price_Rule_vod)
where current date is between Start Date (Start_Date_vod__c)
and End Date End_Date_vod__c)
.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
product
|
string | Specifies the record ID of the product of which to get the List Price for. |
callback
|
function | Call back function which is used to return the information. |
Deprecated:
- Please use getListPrice_Product_Account(product,account,callback)
Returns:
Type
object
getListPrice_Product_Account(product, account, callback)
//first, get the current Account Id and store it in a global variable called 'AccId'
function getCurrentAccount() {
com.veeva.clm.getDataForCurrentObject("Account","Id",getOrderProducts);
}
//get all records aligned to the current user's MySetup where Product Type = 'Order'
function getOrderProducts(result) {
if (result.success == true) {
AccId = result.Account.Id;
com.veeva.clm.getProduct_MySetup("Order", getRelatedProductGroups);
}
}
//for this example, only use the first Order Product will be used
function getRelatedProductGroups(result){
if (result.success == true) {
com.veeva.clm.getListPrice_Product_Account(result.Product_vod__c[0].Id, AccId, displayPricingRule);
}
}
//retun type is an array of record id's from the Pricing_Rule_vod__c object
function displayPricingRule(result){
if (result.success == true) {
alert(JSON.stringify(result.Pricing_Rule_vod__c));
}
}
Requires an Account be specified in order for any result to be returned.
Returns the record ID for the currently valid List Price (Pricing_Rule_vod__c)
for a specific product (Product_vod__c)
and Account combination. Respects the Account and Account Group List Price hierarchy.
Valid list price = Pricing Rule (Pricing_Rule_vod__c)
of record type List Price (List_Price_Rule_vod)
where current date is between Start Date (Start_Date_vod__c)
and End Date (End_Date_vod__c)
.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
product
|
string | Specifies the record ID of the product of which to get the Pricing Rule for. |
account
|
string | Specifies the Account for which to select List Prices for. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getApprovedDocument(vault_id, document_num, callback)
//generally, this function is only used when Vault Instance Id's and Vaut Document Ids are hard-coded into the CLM content
function getDocId() {
com.veeva.clm.getApprovedDocument("https://my-test-vault.veevavault.com","11",displayDocId);
}
//return type is a single record id from Approved_Document_vod__c
function displayDocId(result) {
if (result.success == true) {
alert(JSON.stringify(result.Approved_Document_vod__c.ID));
}
}
Returns the record ID(s) for the Approved Document which matches the values specified and Status_vod = Approved. Gets the approved document by querying all products of type Detail Topic or Detail and compares against the query of any approved documents with the passed in vault_id and document_num. If there are multiple documents with these same ids, an error is thrown.
Note: This function is not supported in content for the CRM Desktop (Windows) platform.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
vault_id
|
string | Specifies the Vault ID of the Approved Document to retrieve. (Vault_Instance_ID_vod on Approved_Document_vod). |
document_num
|
string | Specifies the document number of the Approved Document to retrieve. (Vault_Document_ID_vod on Approved_Document_vod). |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
launchApprovedEmail(email_template, email_fragments, callback)
//generally, getApprovedDocument is only used when Vault Instance Id's and Vaut Document Ids are hard-coded into the CLM content
//store Email Template id in a global variable called "myTemplate"
function getTemplateDocId() {
com.veeva.clm.getApprovedDocument("https://my-test-vault.veevavault.com","11",getFragmentId);
}
//also get an Email Fragment
function getFragmentId(result) {
if (result.success == true) {
myTemplate = result.Approved_Document_vod__c.ID;
com.veeva.clm.getApprovedDocument("https://my-test-vault.veevavault.com","33",launchAE);
}
}
function launchAE(result) {
if (result.success == true) {
com.veeva.clm.launchApprovedEmail(myTemplate, result.Approved_Document_vod__c.ID, callback);
}
}
function callback(result) {}
Launches the Send Email user interface with the email template and fragments selected. An Account must be selected. If CLM_Select_Account_Preview_Mode Veeva Setting is enabled, then Select Account dialogue is opened so the user can select an account. If the Veeva Setting is not enabled and no Account is selected, then no action is performed.
Areas of Use
MyInsights
Parameters:
Name | Type | Description |
---|---|---|
email_template
|
string | Specifies the record ID of the Email Template to use. |
email_fragments
|
string | Array or string with comma separated values of record IDs of the Email fragments to use. Can be made optional by putting in "". |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getDataForCurrentObject(object, field, callback)
Returns the value of a field for a specific record related to the current call.
Areas of Use
MyInsights, CLM, Engage Meeting, Engage for Portals (for Account_vod object only)
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | Limited to the following keywords: Account, TSF, User, Address, Call, Presentation, KeyMessage, and CallObjective. |
field
|
string | Field api name to return a value for. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getDataForObject(object, record, field, callback)
function AccountNoTypeJS(frm){ com.veeva.clm.getDataForObject("Account", "001i0000003DW22AAG", "Name", myAllValue); }
function myAllValue(result){ alert(JSON.stringify(result)); }
Returns the value of a field for a specific record.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | Specifies the object api name (object keywords used in getDataForCurrentObject are not valid, except for Account and User). |
record
|
string | Specifies the record id. |
field
|
string | Field api name to return a value for. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
createRecord(object, values, callback)
function createExampleRecord() {
var newRecord = {};
newRecord.Number_Field_1__c = 42;
newRecord.String_Field_1__c = "testing";
com.veeva.clm.createRecord("Custom_Object__c",newRecord, callback);
}
function callback(result){}
Creates a new record for the specified object.
Areas of Use
CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | Specifies the object api name. |
values
|
object | Json object with the fields and values to be written to the new record. |
callback
|
function | Call back function which is used to return the information. |
Returns:
This function returns success: true as long as the user has access to the object. If the user does not have access to one of the fields specified, success: true is still returned, however, and the fields the user does have access to are still updated.
Type
object
updateRecord(object, record, values, callback)
//example updates some fields from the current Account
function getCurrentAccount() {
com.veeva.clm.getDataForCurrentObject("Account","Id",updateAccount);
}
function updateAccount() {
if (result.success == true) {
var newValues = {};
newValues.My_Custom_Field__c = "new value";
newValues.Number_Field_1__c = 42;
com.veeva.clm.updateRecord("Account",result.Account.Id,newValues,callBack);
}
}
function callBack(result){}
Updates a specified record.
Areas of Use
CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | Specifies the object api name. |
record
|
string | Specifies the record id to be updated. |
values
|
object | Json object with the fields and values updated on the record. |
callback
|
function | Call back function which is used to return the information. |
Returns
This function returns success: true as long as the user has access to the object. If the user does not have access to one of the fields specified, success: true is still returned, however, and the fields the user does have access to are still updated.
Type
object
gotoSlide(key, presentation)
function navigateToHomePage() {
com.veeva.clm.gotoSlide("Home_Page","my_hidden_presentation");
//Navigates to the presentation with a Presentation_Id_vod__c field of "my_hidden_presentation"
//Then navigates to the slide within that presentation with the Media_File_Name_vod__c field of "home_page"
}
function navigateToHomePage() {
com.veeva.clm.gotoSlide("Home_Page","");
//Navigates to the slide in the current presentation with the Media_File_Name_vod__c field of "home_page"
}
Navigates to the specified key message (Key_Message_vod__c)
.
Note: This method can be used in PDF documents on the iPad platform.
Areas of Use
CLM, Engage Meeting
Parameters:
Name | Type | Description |
---|---|---|
key
|
string | Populate with the value of the Media_File_Name_vod__c field of the desired slide |
presentation
|
string | Populate with the value of the Presentation_Id_vod__c field of the desired presentation. If left blank, navigates within the current presentation. |
gotoSlideV2(key, presentation)
function navigateToHomePage() {
com.veeva.clm.gotoSlide("Home_Page","my_hidden_presentation");
//Navigates to the presentation with a Presentation_Id_vod__c field of "my_hidden_presentation"
//Then navigates to the slide within that presentation with the Vault_External_Id_vod__c field of "Home_Page"
}
function navigateToHomePage() {
com.veeva.clm.gotoSlide("Home_Page","");
//Navigates to the slide in the current presentation with the Vault_External_Id_vod__c field of "Home_Page"
}
Navigates to the specified key message (Key_Message_vod__c)
.
Note: This method can be used in PDF documents on the iPad platform.
Areas of Use
CLM, Engage Meeting
Parameters:
Name | Type | Description |
---|---|---|
key
|
string | Message - Vault_External_Id_vod__c field of the key message to jump to. |
presentation
|
string | Vault_External_Id_vod__c of the CLM Presentation if the key message is in a different CLM Presentation. Can be made optional by putting in “”. |
nextSlide()
Navigates to the next slide based on the CLM Presentation Slide display order.
Areas of Use
CLM, Engage Meeting, Engage for Portals
prevSlide()
Navigates to the previous slide based on the CLM Presentation Slide display order.
Areas of Use
CLM, Engage Meeting, Engage for Portals
getUTCdatetime(object, record, field, callback)
//assume "callId" contains a valid record Id of a Call
function getCallDateTime() {
com.veeva.clm.getUTCdatetime("Call2_vod__c",callId, "Call_Datetime_vod__c", displayCallDateTime);
}
//retun type is a single JSON object
function displayCallDateTime(result) {
if (result.success == true) {
alert(JSON.stringify(result.Call2_vod__c.Call_Datetime_vod__c));
}
}
Returns the value of the field in UTC format. Only works with field of type Date or Datetime.
Areas of Use
CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | Specifies the object api name (object keywords used in getDataForCurrentObject are not valid, except for Account). |
record
|
string | Specifies the record id. |
field
|
string | Field api name to return a value for. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
updateCurrentRecord(object, values, callback)
//updates the email addresss against the current Account (only will work against Person Accounts)
function updateAccount() {
var newValues = {};
newValues.PersonEmail = "vern@veeva.com";
com.veeva.clm.updateCurrentRecord("Account",newValues, callBack);
}
function callBack(result){}
Updates the current record related to the call.
Areas of Use
CLM, Engage Meeting
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | Specifies the object api name. |
values
|
object | Json object with the fields and values updated on the record (ignores id field if specified). |
callback
|
function | Call back function which is used to return the information. |
Returns:
Uses saveObjectV2 call. This function returns success: true as long as the user has access to the object and record specified. If the user does not have access to one of the fields specified, success: true is still returned and the fields the user does have access to are updated. If there are fields which are not accessible, code 0200 is returned and the message specifies the field names. If there is no current record (user is in Media Preview), the function is temporarily saved and executed when an Account is selected. If no Account is selected, the function is discarded on exit of Media Preview. The callback function is not executed if there is no current record.
Type
object
formatCreateRecords(objectArray, valueArray)
com.veeva.clm.createRecordsOnExit = function() {
var object1 = "Account";
var values1 = {};
values1.Preferred_Statin__c = "Juvastatin!";
var object2 = "KeyMessage";
var values2 = {};
values2.Customer_Field__c = "Saved information";
var objectArray = [object1, object2];
var valuesArray = [values1, values2];
return com.veeva.clm.formatCreateRecords (objectArray, valuesArray);
}
Formats a string for createRecordsOnExit() and returns it that string.
Areas of Use
CLM, Engage Meeting
Parameters:
Name | Type | Description |
---|---|---|
objectArray
|
array | List of object names. |
valueArray
|
array | List of object values. |
Returns
Type
string
formatUpdateRecords(objectNameArray, objectIdArray, valueArray)
//hard-coded id's are used in this example, and does not represent best practices
com.veeva.clm.updateRecordsOnExit = function() {
var object1 = "Account";
var values1 = {};
values1.Preferred_Statin__c = "Juvastatin";
var object2 = "KeyMessage";
var values2 = {};
values2.Customer_Field__c = "Saved information";
var objectArray = [object1, object2];
var recordIdArray = ["01Id0000001MMt2EAG","01Id0000001MKt8EAJ"];
var valuesArray = [values1, values2];
return com.veeva.clm.formatUpdateRecords (objectArray, recordIdArray, valuesArray);
}
Formats a string for updateRecordsOnExit() and returns it.
Areas of Use
CLM
Parameters:
Name | Type | Description |
---|---|---|
objectNameArray
|
array | List of object names. |
objectIdArray
|
array | List of object Ids. |
valueArray
|
array | List of object values. |
Returns
Type
string
formatUpdateCurrentRecords(objectArray, valueArray)
//formatUpdateCurrentRecords
com.veeva.clm.updateCurrentRecordsOnExit = function() {
var object1 = "Account";
var values1 = {};
values1.Preferred_Statin__c = "Juvastatin";
var object2 = "KeyMessage";
var values2 = {};
values2.Customer_Field__c = "Saved information";
var objectArray = [object1, object2];
var valuesArray = [values1, values2];
return com.veeva.clm.formatUpdateCurrentRecords (objectArray, valuesArray);
}
Creates a string as if it was a request for updateCurrentRecord and returns it that string.
Areas of Use
CLM
Parameters:
Name | Type | Description |
---|---|---|
objectArray
|
array | List of object names. |
valueArray
|
array | List of object values. |
Returns:
Type
string
queryRecord(object, fields [, where] [, sort] [, limit], callback)
function queryAccount() {
var objectName = "Account";
var fields = ["Id","Name"];
var whereClause = "WHERE Specialty_1_vod__c = 'Cardiology'";
var sortClause = ["Name, ASC"];
var limit = "10";
com.veeva.clm.queryRecord(objectName, fields, whereClause, sortClause, limit, displayQueryResults);
}
//return type is an array of objects of the specified object type
function displayQueryResults(result) {
if (result.success == true) {
alert(JSON.stringify(result.Account));
}
}
Queries for, and returns the specified fields for all records which match the where clause. Also returns count of records returned.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
object
|
string | The API Name of the object that you want to query. | |
fields
|
string | Comma delimited string of field API names. | |
where
|
string | optional | String for the where clause. Like. |
sort
|
string | optional | Array of strings which represents the sort, example: ["Name_vod__c, DESC", "Status_vod__c, ASC"]. |
limit
|
string | optional | The maximum number of records to return. |
callback
|
function | Call back function which is used to return the information. |
Where Clause Requirements
Supported clauses, >, <, =, AND, Or, (), <=, >=, , , sort - array consisting of field api names to sort on and either asc or desc ex: ["Name, ASC", "Status_vod__c, DESC"] limit - a positive integer
Returns
Type
object
getFieldLabel(object, fields, callback)
var objectName = "Survey_Question_vod__c";
var fields = ["Answer_Choice_vod__c", "External_ID_vod__c", "Max_Score_vod__c", "Min_Score_vod__c", "Question_vod__c", "Order_vod__c", "Text_vod__c", "Required_vod__c", "Survey_vod__c"];
function get_Field_Labels(frm){
alert("get_Field_Labels");com.veeva.clm.getFieldLabel(objectName, fields, show_Field_Results);
}
function show_Field_Results(results){
if (results.success) {
for (var index in results[objectName]) {
alert("Record " + results[objectName][index]);
}
} else {
alert("Failed: " + " = "+ (JSON.stringify(results)));
}
}
Returns the translated label for each of the specified fields.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | The API Name of the object that you want to query. |
fields
|
array | Array of Field API Names. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getRecordTypeLabels(object, callback)
function getAccountRecordTypeLabels() {
com.veeva.clm.getRecordTypeLabels("Account",displayAccountRecordTypeLabels);
}
//return type is an object of key-value pairs where the key is the recordType API name, and the value is the translated recordtype label
function displayAccountRecordTypeLabels(result) {
if (result.success == true) {
alert(JSON.stringify(result.Account));
}
}
Returns each record type's API name and record type translated label.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | API Name of the object to get all record types for. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
getPicklistValueLabels(object, field, callback)
function getSpecialties() {
com.veeva.clm.getPicklistValueLabels("Account","Specialty_1_vod__c", displaySpecialtyValues);
}
//return type is an object of key-value pairs where the key is the picklist value API name, and the value is the translated picklist label
function displaySpecialtyValues(result) {
if (result.success == true) {
alert(JSON.stringify(result.Account))
}
}
Returns the translated label for each of the picklist values of the specified field.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | API Name of the object. |
field
|
array | API Name of the picklist field. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
getObjectLabels(objects, callback)
function getLabels() {
com.veeva.clm.getObjectLabels(["Call2_vod__c","Medical_Inquiry_vod__c"], displayObjectLabels);
}
//return type is a number of JSON object corresponding to the array of objects passed into the function
//for each object, there is a key-value pair for each label type.
//one label for "plural" and one label for "singular"
function displayObjectLabels (result) {
if (result.success == true) {
alert(JSON.stringify(result.Call2_vod__c.plural));
alert(JSON.stringify(result.Call2_vod__c.singular));
alert(JSON.stringify(result.Account.singular));
alert(JSON.stringify(result.Account.plural));
}
}
Returns object translated labels array for each object API name.
Areas of Use
MyInsights, CLM
Parameters:
Name | Type | Description |
---|---|---|
objects
|
array | Array of object API Names to get translated labels for. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
launchSelector(presentationSlides, callback)
function LaunchSelectorKeyMessages(frm){
divEle = document.getElementById("returned_result");
com.veeva.clm.launchSelector([{"Training_PID": [ "More-Than-1-TRAIN.zip", "More-Than-1-TRAIN50.zip", "More-Than-1-TRAIN75.zip", "More-Than-1-TRAIN100.zip", "More-Than-1-TRAIN125.zip" ]}], LSCallback);
}
Shows the slide selector with specified presentation: key messages; callback gets notified if there are not any valid key messages. The selector displays presentations in the same order as requested, but slides are in the order as defined in the presentation, not the order specified in the request.
Areas of Use
CLM
Parameters:
Name | Type | Description |
---|---|---|
presentationSlides
|
array | Array of presentation slide objects. |
callback
|
function | Call back function which is used to return the information. |
Returns:
Type
object
createMultichannelActivityLine(values, callback)
function buildMCActivity() {
var newValues = {};
newValues.Custom_Field_1__c = "NewField";
newValues.Color_vod__c = "Red";
newValues.Event_Type_vod__c = "Clickstream_vod";
com.veeva.clm.createMultichannelActivityLine(newValues,callBack);
}
function callBack(result) {}
Creates a new record for Multichannel activity lines. The Engage code automatically fills in the Multichannel Activity, Asset Version, Asset VExternal ID, Call (if there is one), DateTime, Debug?, Multichannel Content, Multichannel Content Asset, Sent Email (if there is one), View Order (if Event Type = Slide View). Custom = "True" always sets and the Name is autonumbered. If not specified with custom values, Detail Group, Detail Group VExternal Id, Key Message, Key Message VExternal ID, Product, Product VExternal ID are also automatically filled in.
Areas of Use
Engage
Parameters:
Name | Type | Description |
---|---|---|
values
|
array | JSON object with the fields and values updated on the record. |
callback
|
function | Call back function which is used to return the information. |
Returns
Type
object
request(config, callback)
Returns data requested from the specified external application. To successfully request data online, developers must ensure the specified external application allows cross-origin requests from SFDC.
Note: Videos are not supported in the CRM Engage app.
Areas of Use
CLM
Parameters:
Name | Type | Description |
---|---|---|
config
|
object | A configuration object used to pass in required values for the defined properties. |
callback
|
function | Call back function used to return the information. |
Properties:
Name | Type | Description |
---|---|---|
url
|
string | The URL to which to send the request. Required. |
method
|
string | The HTTP method to use for the request. Default is GET. The TRACE method cannot be used for the Windows platform. Optional. |
headers
|
object | A list of HTTP headers to include with the request. All values must be strings. Optional. |
body
|
string, object | The body data to include with the request. Optional. |
timeout
|
number | The number of seconds to wait for a response before expiring the request. Default is 30. Optional. |
expect
|
"text", "blob" | Defines whether the response body should be interpreted as text or a binary file. Default is text. If the expect value is text but the returned value is not text, the Windows and Online platforms return nonsense text. Optional. |
Returns
Type
text