Vault CRM
X-Pages JavaScript Library for Vault CRM
Download the X-Pages JavaScript library for Vault CRM below:
The X-Pages library is dependent on the Q library which enables users to work with promises as returns from the X-Pages library methods. Include the Q library as a script in the custom report package.
DataService
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'.
Methods
The X-Pages JavaScript Library does not contain the runQuery method. When developing content using the X-Pages JavaScript Library, use the appropriate methods to query the data or metadata you need, including queryRecord, getPicklistValueLabels, getObjectMetadata, getObjectLabels, and getFieldLabels.
getDataForCurrentObject(object, field)
Request
ds.getDataForCurrentObject('account__v', 'credentials__v').then(handleSuccess, handleError);
Returns the value of a field for a specific record related to the current object.
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 retrieve a value. |
Returns:
The promise returned when resolved will return the results of the query.
Objects supported by entry point:
Entry Point |
Supported Objects |
---|---|
Account |
|
Account Plan |
|
Homepage |
|
Territory Feedback |
|
getFeedbackData()
Response
{
"accountDetailMetadata" : [
{
"label" : "Name",
"name" : "account__aln.name__v",
"type" : "STRING"
},
{
"label" : "ID",
"name" : "account__aln.id",
"type" : "STRING"
},
],
"addedAccounts" : 48,
"droppedAccounts" : 0,
"addedBrickCodes" : [ "9455", "90210" ],
"droppedBrickCodes" : [ "92184" ],
"addedZipcodes" : [ "12345" ],
"droppedZipcodes" : [ "94555" ],
"approvedChallengeAccounts" : 0,
"businessAccounts" : 0,
"canChallenge" : false,
"canReview" : false,
"dueDate" : "25\/08\/2022",
"endDate" : "30\/09\/2022",
"goalMetadata" : [
{
"channelOrProductName" : "Face to Face",
"dailyActivityGoal" : 6,
"defaultGoal" : 3,
"defaultMaxGoal" : 6,
"id" : "OPG000000021001",
"products" : [
{
"channelOrProductName" : "Cholecap",
"dailyActivityGoal" : null,
"defaultGoal" : 3,
"defaultMaxGoal" : 6,
"id" : "OPK00000001O001",
"products" : [
]
},
]
}
],
"instructions" : "Test Team Goals",
"manager" : false,
"modelDescription" : "Test Team Goals",
"pendingChallengeAccounts" : 1,
"personAccounts" : 48,
"productMetricMetadata" : {
"metrics" : [
{
"apiName" : "trx__aln",
"label" : "TRx",
"type" : "NUMBER"
},
{
"apiName" : "pmetricnum__c",
"label" : "pmetricNum",
"type" : "NUMBER"
},
],
"products" : [
"CatPro",
"Cholecap",
"Labrinone",
"Restolar"
]
},
"readOnly" : false,
"rejectedChallengeAccounts" : 0,
"startDate" : "1\/1\/2023",
"status" : "Feedback",
"targetAccounts" : 48,
"targetingEnabled" : true,
"teamSellingEnabled" : true,
"territoryDescription" : "VT, MA",
"territoryId" : "OP2000000001002",
"territoryName" : "Feedback1 Territory",
"totalGoals" : [
{
"channelOrProductId" : "OPG000000002001",
"label" : "Multichannel Activity",
"products" : [
{
"channelOrProductId" : "OPK000000002001",
"label" : "Cholecap",
"totalGoal" : "126"
},
],
"totalGoal" : "288"
}
],
"workingDays" : 260,
"accountData" : [
{
"accountChallengeReasons" : [ ],
"accountChallengeStatus" : null,
"accountChallengeType" : null,
"accountDetails" : {
"account__aln.name__v" : "Coireall Abraham",
"account__aln.source__aln" : "Crm",
}
"addresses" : [
"Short Address, Stuttgart",
"A really long address"
],
"firstName" : "Coireall",
"formattedName" : "Abraham, , Coireall",
"goalDetails" : [
{
"channelOrProductId" : "OPG00002002",
"feedbackGoal" : 7,
"goal" : 6,
"maxGoal" : 8,
"productGoals" : [
{
"channelOrProductId" : "OPK1O001",
"feedbackGoal" : null,
"goal" : 2,
"maxGoal" : 3,
"productGoals" : [],
"segment" : "Cholecap",
"teamGoal" : 4
},
],
"segment" : "Calls Activity",
"teamGoal" : 26
},
]
"id" : "A0C000000007311",
"lastName" : "Abraham",
"person" : true,
"productMetricDetails" : [
{
"metric" : "name__v",
"productMetricValues" : {
"CatPro" : "PM-0327",
"Cholecap" : "PM-0258",
"Labrinone" : "PM-0257"
}
},
"target" : true,
"targetChallengeReasons" : [ ],
"targetChallengeStatus" : "Challenged",
"targetChallengeType" : "GoalEdit",
"team" : [
{
"teamMemberGoals" : [
{
"channelOrProductId" : "",
"feedbackGoal" : null,
"goal" : 3,
"maxGoal" : null,
"productGoals" : [
{
"channelOrProductId" : "",
"feedbackGoal" : null,
"goal" : 2,
"maxGoal" : null,
"productGoals" : [],
"segment" : null,
"teamGoal" : null
},
],
"teamMemberName" : "April Levine",
"teamMemberTerritoryDescription" : "Greater Boston",
"teamMemberTerritoryName" : "US Cardio Sales East NE 2"
}
]
}
This method retrieves data about upcoming changes to the current territory and is only used with Territory Feedback in Align.
Parameters:
The default behavior of the method returns the full set of data.
Returns:
When the request is successful, the method returns feedback data in JSON format, which can then be leveraged by content developers:
Field |
Description |
---|---|
accountDetailMetadata
|
Metadata of the labels used to identify account detail information. Contains the following attributes:
|
addedAccounts
|
The total number of accounts that have been added to the territory. |
crmUserId
|
The array of IDs of CRM users that have been assigned to the territory. |
droppedAccounts
|
The total number of accounts that have been dropped from the territory. |
addedBrickCodes
|
List of brick codes that have been added. |
droppedBrickCodes
|
List of brick codes that have been dropped. |
addedZipcodes
|
List of zip codes that have been added. |
droppedZipcodes
|
List of zip codes that have been dropped. |
approvedChallengeAccounts
|
The total number of accounts with approved challenge statuses. |
businessAccounts
|
The total number of business accounts in the territory. |
canChallenge
|
Determines if the user can make challenges. |
canReview
|
Determines if the user can review the territory. |
dueDate
|
Date that the data for territory must be submitted by. |
endDate
|
End date of the cycle. If no cycle exists this field represents the end date of the territory. |
goalMetadata
|
Contains information about goals in the territory:
|
instructions
|
Instructions listed specifically for the territory. |
manager
|
Determines if the current user a manager. |
modelDescription
|
Description of the model. |
pendingChallengeAccounts
|
The total number of accounts with pending challenge status. |
personAccounts
|
The total number of person accounts in the territory. |
productMetricMetadata
|
Contains information about product metrics associated with the territory:
|
readOnly
|
Determines if the territory is in read-only mode. |
rejectedChallengeAccounts
|
Total number of accounts with rejected challenge statuses. |
startDate
|
Start date of the cycle. If no cycle exists this field represents the start date of the territory. |
status
|
The current feedback state of the territory. |
targetAccounts
|
The total number of targets in the territory. |
targetingEnabled
|
Determines if the territory has targeting enabled. |
teamSellingEnabled
|
Determines if Team Selling is enabled. |
territoryDescription
|
The description of the territory. |
territoryId
|
The ID of the territory. |
territoryName
|
The name of the territory. |
totalGoals
|
The number of total goals calculated for each channel and product. Contains the following attributes:
|
workingDays
|
The number of working days in the territory. |
accountData
|
Details data about each account in the territory. If Location Based Targeting is enabled, data from this field represents each combination of an account and its associated addresses. Contains the following attributes:
|
addedTargets
|
The total number of targets added to the territory. |
droppedTargets
|
The total number of targets dropped from the territory. |
isAddedTarget
|
Designates an account as being added as a target. |
isDroppedTarget
|
Designates an account as being dropped as a target. |
daysOffCycle
|
The value of the days_off_cycle__aln field of the associated territory. |
territoryCapacity
|
The value of the territory_capacity__aln field of the associated territory. |
cycleCapacity
|
The value of the cycle_capacity__aln field of the associated territory. |
upperUtilizationThreshold
|
The value of the upper_utilization_threshold__aln field of the associated territory. |
lowerUtilizationThreshold
|
The value of the lower_utilization_threshold__aln field of the associated territory. |
overReachedThreshold
|
The value of the over_reached_threshold__aln field of the associated territory. |
underReachedThreshold
|
The value of the under_reached_threshold__aln field of the associated territory. |
getFieldLabels(queryConfig)
Return the labels for the list of fields passed in.
Request
var queryConfig = {
object: "account__v",
fields: ["name__v", "do_not_call__v"],
};
ds.getFieldLabels(queryConfig).then(handleSuccess, handleError);
Response
[
{
"name": "name__v",
"display": "Name"
},
{
"name": "do_not_call__v",
"display": "Do Not Call?"
}
]
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 list of requested field labels.
getObjectTypes(object, includeInactive)
Queries information about the object types for an object. End users must have Read permission to the object and its object types. By default, only active object types are returned.
Response
{
"account__v": [
{
"name": "professional__v",
"label": "Professional",
"id": "OOT00000000V291",
"isActive": true
}
...
]
}
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | API name of the target object |
includeInactive
|
boolean | Indicates whether to include inactive object types. Optional. Defaults to false. |
Returns:
The promise returned when resolved returns the following information for each object type for the provided object:
- API name
- Translated label
- ID
- Boolean indicating if the object type is active
getObjectLabels(object)
Returns the labels for the list of object names passed in.
Request
var objects = ["call2__v", "medical_event__v"];
ds.getObjectLabels(objects).then(handleSuccess, handleFailure);
Response
{
"success":true,
"call2__v":[
{
"plural":"Calls",
"singular":"Call"
}
],
"medical_event__v":[
{
"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 returns the list of requested object labels.
getPicklistValueLabels(object, field, includeInactive)
Response
{
"account__v":{
"career_status__v":[
{
"name": "emerging__v",
"label": "Emerging",
"isActive": true
},
{
"name": "peak__v",
"label": "Peak",
"isActive": true
},
{
"name": "retired__v",
"label": "Retired",
"isActive": false
}
...
]
}
}
Returns the translated label for each of the picklist values of the specified field.
Parameters:
Name | Type | Description |
---|---|---|
object
|
string | API Name of the target object |
field
|
string | API Name of the target picklist field |
includeInactive
|
boolean | Indicates whether to include inactive picklist values. Optional. Defaults to false. |
Returns:
The promise returned when resolved returns the following information for each picklist value for the provided field:
- API name
- Translated label
- Boolean indicating if the picklist value is active
getMessages(tokens)
Request
var tokens = [{ group: "Common", name: "OK", default: "OK" }, { group: "Common", name: "Wat", default: "Wat" }];
ds.getMessages(tokens).then(handleSuccess, handleError);
Returns the translated value of each of the tokens passed in. The tokens must be case sensitive and exactly match the Vault record.
Parameters:
Name | Type | Description |
---|---|---|
tokens
|
array | A list of string tokens to be translated. |
Returns:
The promise returned when resolved will return the results of the query.
getMediaImagesForSlides(slideIds)
Returns the thumbnail and preview image URLs for specific CLM slides.
Parameters:
Name | Type | Description |
---|---|---|
slideIds |
array of strings |
An array of key message record IDs |
Returns:
When the query is successful, the promise returns the thumbnail and preview image URLs for each requested slide.
getFirstSlideForPresentations(presIds)
Request
var presentations = [ "1234" , "2345" , "3456" } ]
ds.getFirstSlideForPresentations(presentations);
Returns the name, record ID, and media file name for the first slide in specific CLM presentations.
Parameters:
Name | Type | Description |
---|---|---|
presIds |
array of strings |
An array of CLM presentation record IDs |
Returns:
When the query is successful, the promise returns data for the first slide of each requested presentation.
getMediaImagesForPresentations(presIds)
Request
var presentations = [ "1234" , "2345" , "3456" } ]
ds.getMediaImagesForPresentations(presentations);
Returns the thumbnail and preview image URLS for the first slide in specific CLM presentations.
Parameters:
Name | Type | Description |
---|---|---|
presIds |
array of strings |
An array of CLM presentation record IDs |
Returns:
When the query is successful, the promise returns the thumbnail and preview image URLs for the first slide of each requested presentation.
queryRecord(queryConfig)
This method returns the raw data as key value pairs without adding additional metadata (e.x., object labels, field labels etc.) in the returned results. Fields must only be specified once per query or an error is returned. Queried field names are case sensitive.
X-Pages content using platform-specific syntax is not supported. Since queries are executed differently on each platform, results may vary for the same query. For more information, see VQL documentation for queries on the Browser platform and Core Data Predicate Format String Syntax for queries on the iPad and iPhone platforms.
Request
var queryConfig = {
object: "Account",
fields: ["Name", "Phone", "Fax"],
limit: 3
};
ds.queryRecord(queryConfig).then(handleSuccess, handleError);
{
"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. Case sensitive. |
where
|
string | The where statement without the "where" string. Do not include if empty. Strings are case sensitive in content deployed to iPad. ex: where: "Name = 'Accessing X-Pages'" |
sort
|
array of strings | The sort statement without the “order by” string. Do not include if empty. ex: sort: ['call_date__v DESC'] |
limit
|
number | The maximum number of records to return |
Returns:
When resolved, the promise will return the results of the query.
newRecord(configObject)
The newRecord method displays the native interface of the object within Veeva CRM.
Developers can use the newRecord method to create and send Approved Emails (sent_email__v records) from X-Pages. However, only the account__v, approved_email_template__v, and email_fragments__v fields are supported.
var configObject = {
object: "call2__v",
fields: {
account__v: "00161000004vuXMAAY"
}
};
ds.newRecord(configObject).then(handleSuccess, handleError);
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 from a X-Pages tab in one record/location to a target record/location. If the target record/location is an Account with one or more X-Pages tabs, developers can specify a target tab to navigate to directly. Users can navigate back to the original X-Pages report by selecting back, returning to their last viewed screen.
When navigating to X-Pages reports for the first time, the last modified report displays.
Developers can use the viewRecord method to view sent_email__v records from X-Pages.
Request
var configObject = {
object: "call2__v",
fields: {id: "a040U000000UJPUQA4"}
};
function launchCall() {
ds.viewRecord(configObject).then(handleSuccess, handleError);
}
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 |
target
|
object, list of objects |
Using more than 20 navigation targets is not supported. Can be one of the following:
When navigating to a case__v record, developers can use either the name__v field or ID of the record, but using the name__v field is preferred. |
Returns:
When the request is successful, the application displays the native interface.
viewSection(target)
The viewSection method navigates from one X-Pages tab to another within the current record/location. This method is only supported for account-level or territory-level content.
Request
function viewAcct() {
ds.viewSection({id: "a040U000000UJPUQA4"}).then(handleSuccess, handleError);
}
Parameters:
Name | Type | Description |
---|---|---|
configObject
|
object, list of objects |
One of the following:
Using more than 20 navigation targets is not supported. |
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 Vault.
Response
{
"success":true,
"data":{
"sample_lot__v":{
},
"user__sys":{
},
"assortment__v":{
},
"event_attendee__v":{
}
},
"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 |
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.
executeSuggestionAction(SuggestionId,actionType,bulkExecution)
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__v",
fields: ["Title__v", "RecordTypeId", "Posted_Date__v"],
where: "Account__v = _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:
|
|
string |
Optional. Only applies when actionType = “execute” and the Suggestion Type is Call2__v. Determines how many active Call Suggestions to send to My Schedule. Supports the following values: “none” or null - send only the record with SuggestionId“allAccount” - sends all active Call Suggestions for the Suggestion’s account“allUser” - sends all active Call Suggestions for the current user |
Returns:
When the request is successful, the desired action is made against the specified suggestion. The success flag in the returned JavaScript payload indicates the suggestion was marked as Actioned.
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 specific key message in a CLM presentation directly from X-Pages content or launching the CLM media library.
Launching a CLM Presentation to a Specific Slide
ds.launchMediaForAccount("acct","MyPresentation","HomePage");
//Launches the CLM presentation with a presentation_id__v field of "MyPresentation"
//and goes directly to the Key Message in that presentation with a media_file_name__v 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__v field of the CLM_Presentation__v record you want to launch |
keyMessageMediaFileName
|
string | Enter the Media_File_Name__v field of the Key_Message__v record to directly open |
The presentationId and keyMessageFileName parameters must be used together. Either both are populated or both are blank.
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.
getCurrentPosition()
Returns the geographic location of the user’s device, enabling developers to use the location values to create content which help users plan activities, for example, by marking the device’s location on a map (for example, Google Maps), comparing and displaying distances to account locations, or creating a location log.
This method supports asynchronous calls.
For iPad and iPhone devices, location data returned from this method remains cached for 2 minutes. If a request is made within 2 minutes of the previous request, the method returns the cached location data.
Request
ds.getCurrentPosition();
//Queries the device's current location coordinates from Veeva CRM
//CRM returns location data received from the device's internal GPS
Success Response
{
"success": true,
"coordinates": {
"latitude": 37.804363,
"longitude":-122.271111,
"accuracy": 4},
"timestamp": 1533729980953.91
}
Returns:
When the request is successful, the promise returns the results of the query, including:
- Timestamp
- Latitude
- Longitude
- Accuracy
createRecord(configObject)
Creates a record for the specified object directly from X-Pages content. X-Pages content does not support using browser APIs for storage, for example, Web Storage and IndexedDB. Instead, developers can save data to myinsights_data__v records.
createRecord(configObject)
var configObject = {
object: "myinsights_data__v",
fields: {
"html_report__v": "a060U000000ERGFQA8",
"mobile_id__v": "a040U000000UJPUQA4",
"custom_field__c": "value"
}
};
ds.createRecord(configObject).then(handleSuccess, handleError);
Parameters:
Name | Type | Description |
---|---|---|
configObject
|
object | {object: string, fields: object} |
Properties:
Name | Type | Description |
---|---|---|
object
|
string | The API name of the object to create. |
fields
|
object | Key-values pair of the API names of fields and the values to store in each field. |
Returns:
When the request is successful, the method returns the ID of the created record.
updateRecord(configObject)
Updates fields on the specified record directly from X-Pages content.
Veeva does not recommend using this feature with Veeva objects. Specifically, it does not work with Call-related objects on offline platforms.
On the online platform, calling updateRecord always updates the Last Modified and Last Modified By fields on the record. The Last Modified time matches the time of the update.
On mobile platforms, calling updateRecord only updates the Last Modified and Last Modified By fields when data on the record is changed. The Last Modified time matches the time of the sync.
updateRecord(configObject)
var configObject = {
object: "myinsights_data__v",
id: "a040U000000UJPUQA4",
fields: {
"custom_field1__c": "newValue1",
"custom_field2__c": "newValue2"
}
};
ds.updateRecord(configObject).then(handleSuccess, handleError);
Parameters:
Name | Type | Description |
---|---|---|
configObject
|
object | {object: string, fields: object} |
Properties:
Name | Type | Description |
---|---|---|
object
|
string | The API name of the object to update. |
id
|
string | The Mobile ID or Vault ID of the record to update. |
fields
|
object | Key-values pair of the API names of fields and the values to store in each field. |
Returns:
When the request is successful, the method returns the ID of the updated record.
request(configObject)
Returns data requested from the specified external application. This method can be called multiple times to send parallel requests. See Integrating External Data with X-Pages for more information.
To successfully request data online, developers must ensure the specified external application allows cross-origin requests from Vault CRM.
request(configObject)
var configObject = {
url: "http://example.com",
method: "GET",
headers: {
"Accept-Language": "en-US",
"Other-Header": "etc"
},
body: "example body",
timeout: 30,
expect: "text"
};
ds.request(configObject).then(handleSuccess, handleError);
Parameters:
Name | Type | Description |
---|---|---|
configObject
|
object | A configuration object used to pass in required values for the defined properties. |
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:
When the request is successful, the promise returns a JSON object containing the requested data as a string.
queryVDSRecord(queryConfig)
Returns data records from Nitro. Queried field names are case sensitive.
Since queries are executed differently on each platform, results may vary for the same query. For more information, see SOQL Condition Expression Syntax for queries on the Online platform and Core Data Predicate Format String Syntax for queries on the iPad and iPhone platforms.
var queryConfig = {
object: "name_of_some_nitro_table",
fields: ["a_field", "another_field"],
limit: 100,
sort: ["a_third_field ASC"],
where: "example_rolling_week_num < 2"
};
ds.queryVDSRecord(queryConfig).then(handleSuccess,handleFailure);
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 data table to query |
fields
|
array of strings | An array of column API Names to return. Case sensitive. |
where
|
string | The where statement without the "where" string. Do not include if empty. |
sort
|
array of strings | The sort statement without the “order by” string. Do not include if empty. |
limit
|
number | The maximum number of records to return |
Returns:
When the query is successful, the promise returns the results of the query.
queryDataEngine(dataEngineConfig)
Returns large data sets from the CRM Data Engine. This method leverages CRM Data Engine’s ability to handle complex queries, including group-by logic and calculation of formula fields. By using this method, report creators can improve performance of the report and reduce the amount of JavaScript they need to write to process the data.
Example
var DataEngineConfig = {
table: "compass_trx_monthly_summary_raw__v",
fields: [
"account_id__v",
"product_name__v",
"market_id__v",
{
"type": "concat",
"value": [
"transaction_year__v",
{
"type": "quote",
"value": "-",
},
"transaction_month__v"
]
"as": "year_month",
},
{
"type": "sum",
"field": "value__v",
"as": "total",
}
],
where: {
"type": "allOf",
"subclauses": [
{
"field": "territory_id__v",
"operator": "in",
"value": [ /*ids from myTerritories variable */ ]
},
{
"field": "market_id__v",
"operator": "eq",
"value": "TEST001"
}
]
},
sort: [
{ "field": "account_id__v", "order": "asc" },
{ "field": "product_name__v", "order": "desc" }
],
limit: 100
};
ds.queryDataEngine(DataEngineConfig).then(handleSuccess,handleFailure);
Parameters:
Name | Type | Description |
---|---|---|
dataEngineConfig |
object |
{table: String, fields: Array, where: Object, sort: Array, limit: Number} |
Properties:
Name | Type | Description |
---|---|---|
table |
string |
Name of the table to query |
fields |
array |
An array of fields to query. These fields can include dimensions (string values calculated from expressions) and metrics (number values calculated from expressions). |
where |
object |
A condition to filter the returned data |
sort |
array |
An array defining the order of the returned data. Includes the sort direction and the field on which to sort. |
limit |
number |
The number of results to return. Optional. |
Returns:
When the query is successful, the promise resolves with the requested data.
getDataEngineTables()
Returns a list of all tables that can be queried by the current user.
Returns:
When the request is successful, the promise resolves with a list of the names of the tables the user can query.
getDataEngineTableMetadata(tableName)
Returns the metadata of a specific table in the CRM Data Engine.
Parameters:
Name | Type | Description |
---|---|---|
tableName |
string |
The name of the table to query |
Returns:
When the request is successful, the promise resolves with the columns in the queried table.
getAlignedTerritories(configObject)
Returns a list of aligned territories for the current user. This can include the child territories for each aligned territory.
Parameters:
Name | Type | Description |
---|---|---|
configObject |
object |
{includeChildren: Boolean} |
Properties:
Name | Type | Description |
---|---|---|
includeChildren |
boolean |
Determines whether to include data for the child territories for each aligned territory. Optional. |
Returns:
When the request is successful, the promise resolves with a list of territories aligned to the user, including each territory’s name, ID, developer name, and parent territory ID.
sendToMySchedule(configObject)
Displays the My Schedule screen with the specified accounts selected for users to schedule calls with. Users can return to the X-Pages content via the Back button. This method is supported for the Territory, Account, and Account Plan entry points.
This method is only supported on the iPad platform.
Example
var configObject = {
accountIds:[ "SOME_SFDC_ID" , "SOME_MOBILE_ID" , "ANOTHER_SFDC_ID" ]
};
ds.sendToMySchedule(configObject).then(handleSuccess, handleFailure);
Parameters:
Name | Type | Description |
---|---|---|
configObject
|
object | {accountIds: array} |
Properties
Name | Type | Description |
---|---|---|
accountIds
|
array of strings | An array of Account IDs. Can be Vault IDs or mobile IDs. Can be empty. |
Returns:
The promise returns a success code when resolved successfully.
refreshOrder()
This method can be embedded in a button or link to display the Order Lines tab for an order and recalculate the order based on the pricing rules. To avoid unexpected navigation away from the visualization, developers should make sure this method is embedded in an obviously actionable element.
This method is only supported for the Order entry point on the iPad platform.
Returns:
The method returns a promise. When resolved, it returns and navigates to the Order Lines tab.
getVaultSessionId()
Returns information about the current Vault instance, including a valid Vault session ID. This ID cannot be used to directly authenticate to an external application. Developers must pass this ID into a customer-defined authentication process accepted by the specified external application. See Integrating External Data with X-Pages for more information.
Returns:
When the request is successful, the promise returns a JSON object containing the Vault Session Id, URL of the Vault instance, and a boolean value to determine if the Vault is a sandbox.
getSSOAccessToken(providerName)
Returns a valid SSO access token. Used to authenticate with SSO for external applications when integrating external data in content. See Integrating External Data with X-Pages for more information.
Parameters:
Name | Type | Description |
---|---|---|
providerName |
string |
Identifies the SSO provider of the access token. This must be the API Name of an X-Page SSO Configuration record. Required. |
Returns:
When the request is successful, the promise returns a valid SSO access token as a string.
request(configObject)
Returns data requested from the specified external application. This method can be called multiple times to send parallel requests.
To successfully request data online, developers must ensure the specified external application allows cross-origin requests from Vault.
On the Browser platform, the object passed in as the argument must be a string. Developers can use JSON.stringify to convert objects into strings.
Example
var configObject = {
url: "http://example.com",
method: "GET",
headers: {
"Accept-Language": "en-US",
"Other-Header": "etc"
},
body: "example body",
timeout: 30,
expect: "text"
};
ds.request(configObject).then(handleSuccess, handleFailure);
Parameters:
Name | Type | Description |
---|---|---|
configObject
|
object | A configuration object used to pass in required values for the defined properties. |
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:
When the request is successful, the promise returns a JSON object containing the requested data as a string.