Cards Context Variables (Managed Package)

For the managed package runtime, several variables are available across the framework to provide contexts to cards, data sources, flyouts, templates, and other components.

Managed Package app icon This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.

Note
Note

All variables are case sensitive.

Name

Variable

Access

Example

Page Parameters

Represents the page parameters passed to the URL.

{{params}}

Global

/apex/consolecards?id=123

represents {{params.Id}} ,equaling 123.

Object

The object represented in the card, which holds all the fields and information for the record.

{{obj}}

Card

If the object for the card has an Account such that Name = 'Test', obj.Name = 'Test'.

Parent (for flyouts only)

The parent object of the flyout.

{{parent}}

Global (Flyout)

SELECT Id, Name FROM Contact WHERE AccountId = {parent.obj.Id}

where {parent.obj.Id} equals the ID of the object in the card that contains the flyout.

Parent Layout

Gives access to the parent layout scope.

{{parentLayout}}

Card

 

Attributes

Allows access to the attributes passed to the vloc-card, vloc-layout, and vloc-cmp directives

{{attrs}}

Global

<vloc-card name="community-account" customtemplate="community-sidebar-ads"> </vloc-card>

Access the name and custom template by calling {{attrs.name}} and {{attrs.customtemplate}}.

Session Variables

Variables that are set in the designer for runtime use, they can access any property in the scope plus the {{payload}} variable.

{{session}}

Layout or Card

You can set a session variable to be named: Title and set it to obj.Name in the designer.

Payload

A temporary variable used by the session variables to access the entire result of a data source.

{{payload}}

Layout or Card

The variable holds the entire result of the data source so you can access other properties like payload.totalSize while using a result variable of result.records in the Datasource.

Imported Scope

The framework allows for external modules and controllers to be imported into the cards, layouts, and components. Importing the scope can then extend the functionality of the framework, for example, the {ctrl} attribute.

{{importedScope}}

Global to the inserted component.

If imported into a layout, the cards also have access.

Excerpt from the community templates:

Component with imported ctrl; see ctrl attribute inserted the infoCtrl:


                <vloc-cmp name="frame" customtemplate="community-content-frame" loaded="true" 
ctrl="infoCtrl" ng-show="!$root.showContent"> 
</vloc-cmp>
              

Template using imported logic:

<div class="info">
<h2 ng-click="$root.showContent = !$root.showContent; importedScope.url = '';">
<span class="icon icon-v-left-caret">
</span>Back
</h2>
<iframe ng-src="{{importedScope.url}}" onload="iframeLoaded()"ng-show="importedScope.loaded">
</iframe>
</div>

Controller imported:

.controller('infoCtrl', 
function($scope, $rootScope, remoteActions, force, $sce)
{ $scope.loaded = false;
$rootScope.$on('actionSelected',function(event, action) {
console.log(action.url);
$scope.loaded = false;
$rootScope.showContent = false;
$scope.url = $sce.trustAsResourceUrl(action.url);
});
window.iframeLoaded = function() {
if ($scope.url) {
console.log('Community frame loaded');
$scope.loaded = true;
$scope.$apply();
}
};
});

User Information Variable

Information about the user is fetched on the start of the framework. The information is stored under the $rootScope.vlocity variable and is available inside templates in $root.vlocity.

{{$root.vlocity}}

Layout or Card

Example of a query on a card data source using a contextId: Select AccountId, Account.Name, Name, Birthdate,Phone FROM Contact where AccountId  = '{{$root.vlocity.userAccountId}}'

User information available:

  • User Id: $root.vlocity.userId

  • User Name : $root.vlocity.userName

  • User Type: $root.vlocity.userType

  • User Role: $root.vlocity.user

  • User Profile Id : $root.vlocity.userProfileId

  • User Profile Name : $root.vlocity.userProfileName

  • User Account Id : $root.vlocity.userAccountId

  • User Contact Id : $root.vlocity.userContactId

  • Locale in browser lowercase format : $root.vlocity.userAnLocale 

  • Locale in Salesforce format: $root.vlocity.userSfLocale

  • Currency code: $root.vlocity.userCurrency

  • Language: $root.vlocity.userLanguage

  • Time Zone: $root.vlocity.userTimeZone