Utility Bar API Implementation Guide

Similar documents
Salesforce Mobile App URL Schemes

Getting Started with the Aloha Community Template for Salesforce Identity

Custom Metadata Types Implementation Guide

Custom Metadata Types Implementation Guide

Custom Metadata Types Implementation Guide

Financial Services Cloud Quick Start

Convert Your JavaScript Buttons for Lightning Experience

Lightning Knowledge Guide

Using the Drag-and-Drop Report Builder

Set Up and Manage Salesforce Communities

Create and Manage Partner Portals

Salesforce External Identity Implementation Guide

Snap-Ins Chat. Salesforce, Winter

Identity Implementation Guide

Manage Duplicate Records in Salesforce PREVIEW

RingCentral for Salesforce. Administrator Guide

Identity Implementation Guide

Force.com Streaming API Developer Guide

Sync Your Contacts and Events with Lightning Sync

Package and Distribute Your Apps

Streaming API Developer Guide

LinkedIn Sales Navigator for Salesforce Installation Guide: Lightning View

Document revision 1.0

Salesforce External Identity Implementation Guide

Live Agent for Support Agents

Snap-Ins Chat. Salesforce, Summer

The Admin's Guide to Entitlement Management

Identity Implementation Guide

Package and Distribute Your Apps

Salesforce Classic Mobile User Guide for Android

Field Audit Trail Implementation Guide

Salesforce External Identity Implementation Guide

License Management and Support Guide

RingCentral for Salesforce Classic. UK Administrator Guide

Set Up and Configure Salesforce Advisor Link

Omni-Channel for Administrators

Salesforce Console Implementation Guide for Salesforce Classic

RingCentral for Salesforce. User Guide

Omni-Channel for Administrators

Chatter Answers Implementation Guide

Getting Microsoft Outlook and Salesforce in Sync

USER MANUAL. SalesPort Salesforce Customer Portal for WordPress (Lightning Mode) TABLE OF CONTENTS. Version: 3.1.0

What s New In the Salesforce Winter 15 Release

Salesforce Files Connect Implementation Guide

Force.com Streaming API Developer Guide

Getting Started with the Salesforce Agile Accelerator

Platform Events Developer Guide

Field Audit Trail Implementation Guide

Salesforce Lead Management Implementation Guide

PREVIEW. Field Audit Trail Implementation Guide. Salesforce, Winter

Manage Duplicate Records in Salesforce

Open CTI Developer Guide

Technical Documentation. Configuring Google SSO with Amazon AppStream 2.0 and Amazon AppStream 2.0 Chrome Packaging and Deployment

Getting Microsoft Outlook and Salesforce in Sync

Salesforce Console Implementation Guide

Salesforce Enterprise Edition Upgrade Guide

Sync to a Secondary Salesforce Organization

Live Agent Developer Guide

Enhance Your Sales Cloud Implementation

Akana API Platform: Upgrade Guide

Set Up Salesforce Files Sync

ANALYTICS FOLDER SHARING

This guide covers the installation, setup, and configuration of Sertifi for Salesforce CPQ.

Identity Implementation Guide

INSTALLATION GUIDE. Installing PhoneBurner for Salesforce. PhoneBurner for Salesforce

Account Plan Pro Set Up Guide

Salesforce IoT REST API Getting Started Guide

Force.com Migration Tool Guide

Introduction to Git and GitHub for Writers Workbook February 23, 2019 Peter Gruenbaum

Deploy Enhancements from Sandboxes

TESTING WITH DIFFERENT PROFILES

Identity Implementation Guide

SkyVisualEditor Salesforce1 Support Guide

Visualforce & Lightning Experience

Case Management Implementation Guide

Platform Events Developer Guide

Files to Contents. User Guide March 11, 2008

icontact for Salesforce Installation Guide

Chatter Answers Implementation Guide

Set up your computer to sync your OneDrive for Business files in Office 365

Deploy Enhancements from Sandboxes

Introducing the new Panasonic (PSCNA) Partner Portal. February 2017

Steps for Building a Process Builder to work with Visual Workflow

Health Cloud Implementation Guide

This document explains how to configure FlexApp s Click-to-Layer feature for published applications.

The Admin's Guide to Entitlement Management

Analytics Data Integration Guide

MIGRATING FROM PORTALS TO COMMUNITIES

Salesforce App Help. Salesforce, Winter

Set Up and Maintain Collaboration Tools

Analytics External Data API Developer Guide

SkyVisualEditor Default AppComponent Package User Manual

Salesforce Classic Mobile Guide for iphone

Omni-Channel for Administrators

Setting Up Resources in VMware Identity Manager (SaaS) Modified 15 SEP 2017 VMware Identity Manager

Installation & Configuration Guide Enterprise/Unlimited Edition

Salesforce CLI Command Reference (Beta)

Learning More About NetObjects Matrix Builder 1

NPSP Advanced User's Guide to Importing Data

Salesforce CRM Content Implementation Guide

Transcription:

Utility Bar API Implementation Guide Salesforce, Winter 18 @salesforcedocs Last updated: November 2, 2017

Copyright 2000 2017 salesforce.com, inc. All rights reserved. Salesforce is a registered trademark of salesforce.com, inc., as are other names and marks. Other marks appearing herein may be trademarks of their respective owners.

CONTENTS Utility Bar API Implementation Guide...................................... 1 What Is the Utility Bar?................................................... 1 What Is a Utility?...................................................... 2 Defining a Utility Bar with JSON............................................. 3 Utility Bar Syntax...................................................... 4 Log In to Workbench.................................................... 6 Create a Utility Bar..................................................... 6 Create a Lightning App.................................................. 7 Retrieve your Custom Applications Using the Metadata API......................... 7 Add Your Utility Bar to a Lightning App....................................... 8 Deploy Changes to Your Org.............................................. 9 View the Recent Items Utility Bar in Lightning Experience............................ 9

UTILITY BAR API IMPLEMENTATION GUIDE You can use the Tooling API and Metadata API to create a utility bar and add it to a Lightning app. Tip: You can also set up and configure a utility bar using the Lightning App Wizard in the UI. For detailed information, see Add a Utility Bar to Lightning Apps in the Salesforce online help. IN THIS SECTION: What Is the Utility Bar? Lightning Experience allows you to add your components to prime real estate in any Lightning app so that your users have one-click access to powerful productivity tools. Now, you can access those same productivity tools in a horizontal footer, called the utility bar. What Is a Utility? Utilities are Lightning components defined by a few characteristics. To be a utility, a Lightning component must implement flexipage:availableforallpagetypes, be added to a utility bar FlexiPage, and have utility-specific attributes defined. Defining a Utility Bar with JSON Creating a utility bar is similar to creating any other Lightning page. Unlike other Lightning pages, however, you cannot create or edit utility bars in the Lightning App Builder. Utility Bar Syntax The JSON definition of a utility bar is similar to that of any other Lightning page. Log In to Workbench Use Workbench to make calls to the Tooling API and Metadata API. Create a Utility Bar Use the Tooling API in Workbench to create a utility bar FlexiPage. Create a Lightning App Create a Lightning app to add the utility bar to. Retrieve your Custom Applications Using the Metadata API Use the Metadata API to retrieve information about your org s Lightning apps. Add Your Utility Bar to a Lightning App Add your utility bar to a Lightning app by including the utility bar s FullName in the XML definition of the app. Deploy Changes to Your Org Use the Metadata API to deploy your updated package to your org. View the Recent Items Utility Bar in Lightning Experience What Is the Utility Bar? Lightning Experience allows you to add your components to prime real estate in any Lightning app so that your users have one-click access to powerful productivity tools. Now, you can access those same productivity tools in a horizontal footer, called the utility bar. The utility bar in Lightning Experience combines the best features from home page components in Salesforce Classic and the footer in Salesforce Classic console apps. The utility bar shows components in Lightning Experience so your users can easily access tools like Lightning Voice and Notes. 1

What Is a Utility? The utility bar is implemented as a Lightning page with "type": "UtilityBar" and "pagetemplate": "one:utilitybartemplatedesktop". The utility bar Lightning page includes a single region (1), and, like any other Lightning page, contains Lightning components (2). In this case, these Lightning components are utilities. If this seems confusing right now, don t worry. We ll break it down as we go. Note: A Lightning page region can contain up to 25 components. What Is a Utility? Utilities are Lightning components defined by a few characteristics. To be a utility, a Lightning component must implement flexipage:availableforallpagetypes, be added to a utility bar FlexiPage, and have utility-specific attributes defined. When you add a component to the utility bar, you can define attributes that determine things like the utility s height and width. Other Lightning components that implement flexipage:availableforallpagetypes have other attributes you must define. For example, when you create a report chart component you have to provide a reportid, and decide whether to show the refresh icon. You can create a utility bar using custom Lightning components or out-of-the-box components. You can also easily adapt existing custom Lightning components as utilities by updating them to implement flexipage:availableforallpagetypes. 2

Defining a Utility Bar with JSON This utility bar, built with out-of-the-box Lightning components, displays a report chart using flexipage:reportchart and a list of recently viewed items using flexipage:recentitems. Defining a Utility Bar with JSON Creating a utility bar is similar to creating any other Lightning page. Unlike other Lightning pages, however, you cannot create or edit utility bars in the Lightning App Builder. 3

Utility Bar Syntax A utility bar is a Lightning page of a specific type and pagetemplate. "type": "UtilityBar" "pagetemplate": "one:utilitybartemplatedesktop" In Lightning Experience, Lightning pages also known as FlexiPages are custom layouts that let you design pages. Typically, you create and edit Lightning pages in the Lightning App Builder. Utility bar Lightning pages, however, aren t available in the Lightning App Builder. To create a utility bar, use the Tooling API to POST a JSON definition. The REST endpoint for FlexiPage is /services/data/v38.0/tooling/sobjects/flexipage/. You can create a utility bar and define its components at the same time. For this example, we ll add a single Recent Items component, flexipage:recentitems, to show how the process works. This recentitems component implements flexipage:availableforallpagetypes, which is a required interface for Lightning components added to a utility bar. Utility Bar Syntax The JSON definition of a utility bar is similar to that of any other Lightning page. Once you understand the basic structure of a JSON utility bar definition, it s easy to customize your own by adding out-of-the-box or custom Lightning components. Each utility in any utility bar is defined by five attributes. Height: Optional. The component s height. Width: Optional. The component s width Eager: Optional. Whether the component loads when the app loads. If false, the component loads when a user first opens it. Label: Required. The component s label. Icon: Optional. The component s icon. Supported values for this attribute are listed on the Salesforce Lightning Design System website. Custom icons are not supported at this time. This utility bar has one utility, recentitems, which displays a list of recently accessed records. You also have to define attributes specific to the recentitems FlexiPage: ListItems: Required. An array of sobject types representing which types of record appear in the list of recent items. MaxRecords: Optional. The maximum number of records displayed. "FullName": "recentitemsutility", "Metadata": "masterlabel": "Recent Items Utility Bar", "pagetemplate": "one:utilitybartemplatedesktop", "type": "UtilityBar", "description": "This utility bar displays a list of recently accessed records.", "flexipageregions": [ "appendable": null, "name": "utilityitems", "type": "Region", "componentinstances": [ "componentname": "flexipage:recentitems", "componentinstanceproperties": [ 4

Utility Bar Syntax ] ] ] "name": "entitynames", "value": "['Account']", "name": "maxrecords", "value": "5", "name": "icon", "value": "note", "name": "label", "value": "Recent Items Utility", "name": "width", "value": "425", "name": "height", "value": "320" Let s look at this code line by line. The first thing we define is a FullName, recentitemsutility, which must be unique within your org. Next we define a masterlabel and Description, which are the user-facing label and description, respectively, for this utility bar. To specify that this FlexiPage is utility bar, we set "type": "UtilityBar" and "pagetemplate": "one:utilitybartemplatedesktop". The next chunk of code, starting with "flexipageregions", defines a region within our FlexiPage. Utility bar FlexiPages only have one region, which can contain multiple components. In this case we re going to add one Lightning component, a flexipage:recentitems component, to this region. In general, you can add as many Lightning components as you want to a utility bar. The last section of code, beginning with "componentinstances", defines the attributes specific to the utility bar, as well as attributes specific to the recentitems Lightning component. Notice that we defined "entitynames" as an array that includes only the Account object and "maxrecords" as 5, meaning that the utility will show a maximum of five recently viewed accounts. 5

Log In to Workbench Log In to Workbench Use Workbench to make calls to the Tooling API and Metadata API. You can t create utility bar Lightning pages in the Lightning App Builder. Instead, use a JSON POST request to the Tooling API. Workbench allows you to make API calls from a web browser with a simple and intuitive user interface. 1. Go to https://workbench.developerforce.com/login.php. 2. Choose your environment and API Version. 3. Click Login with Salesforce and enter your credentials. Create a Utility Bar Use the Tooling API in Workbench to create a utility bar FlexiPage. 1. In Workbench, click Utilities > REST Explorer. 2. Enter /services/data/v38.0/tooling/sobjects/flexipage/. 3. Copy the JSON definition of the Recent Items Utility into the Request Body: "FullName": "recentitemsutility", "Metadata": "masterlabel": "Recent Items Utility Bar", "pagetemplate": "one:utilitybartemplatedesktop", "type": "UtilityBar", "description": "This utility bar displays a list of recently accessed records.", "flexipageregions": [ "appendable": null, "name": "utilityitems", "type": "Region", "componentinstances": [ "componentname": "flexipage:recentitems", "componentinstanceproperties": [ "name": "entitynames", "value": "['Account']", "name": "maxrecords", "value": "5", "name": "icon", "value": "note", "name": "label", "value": "Recent Items Utility" 6

Create a Lightning App ] ] ], "name": "width", "value": "425", "name": "height", "value": "320" 4. Click Execute. If you see a success: true message, you ve successfully added the utility bar to your org. Next, add it to a Lightning app. Create a Lightning App Create a Lightning app to add the utility bar to. When you create a Lightning app, it s represented by a customapplication sobject in the Metadata API. 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager. 2. Click New Lightning App, and walk through the New Lightning App wizard. You can give your app a name, set its primary color, give it a logo, customize which items appear in the app s navigation bar, and assign the app to user profiles. Name the app My Lightning App, with the developer name My_Lightning_App. Tip: The app description displays alongside the icon in the App Launcher. Make the description meaningful to your users. Learn more about Lightning apps on Trailhead. Now that you ve created a Lightning app, use the Metadata API to add the recentitemsutility to it. Retrieve your Custom Applications Using the Metadata API Use the Metadata API to retrieve information about your org s Lightning apps. The Metadata API has two types of calls, deploy and retrieve. A retrieve call returns data from your org, while a deploy call updates or inserts data in your org. Use a Metadata API retrieve call to get a list of custom applications in your org, and then add the Recent Items Utility Bar to a Lightning app. 1. In a text editor, copy and paste the following: <?xml version='1.0' encoding='utf-8'?> <package xmlns="http://soap.sforce.com/2006/04/metadata"> 7

Add Your Utility Bar to a Lightning App <types> <members>*</members> <name>customapplication</name> </types> <version>38.0</version> </package> 2. Save the file as package.xml. The package file tells the Metadata API which objects you want to retrieve. This package.xml returns the XML definition of all the Classic apps and Lightning apps in your org. 3. In Workbench, click Migration > Retrieve. 4. Click Choose File and select package.xml. 5. Click Next, then click Retrieve. 6. Wait for the page to refresh and look for success: true in the output. If the call succeeded, click Download ZIP File to save the results. Add Your Utility Bar to a Lightning App Add your utility bar to a Lightning app by including the utility bar s FullName in the XML definition of the app. 1. Unzip the.zip file you downloaded. It should have a name similar to retrieve_09sr00000000qjpmae.zip. 2. Navigate to the applications folder, and open My_Lightning_App.app in a text editor. 3. Copy and paste <utilitybar>recentitemsutility</utilitybar> into the second-to-last line of code, right above </CustomApplication>. It should look something like this: <?xml version="1.0" encoding="utf-8"?> <CustomApplication xmlns="http://soap.sforce.com/2006/04/metadata"> <brand> <headercolor>#fd30d8</headercolor> </brand> <description>my Lightning App</description> <formfactors>large</formfactors> <label>a Lightning App with a utility bar.</label> <navtype>standard</navtype> <tab>standard-account</tab> <tab>standard-case</tab> <tab>standard-product2</tab> <tab>standard-order</tab> <tab>standard-opportunity</tab> <tab>standard-contentnote</tab> <tab>standard-otheruserprofile</tab> <tab>standard-lead</tab> <tab>standard-applauncher</tab> <uitype>lightning</uitype> <utilitybar>recentitemsutility</utilitybar> </CustomApplication> This line of XML ties the utility bar you created earlier, recentitemsutility, to the customapplication sobject you chose. This sobject represents a Lightning app in your org. 8

Deploy Changes to Your Org 4. Save My_Lightning_App.app, and zip the unpackaged directory. The name of the file doesn t matter, so leave it as unpackaged.zip. Important: If you are on macos, create the.zip file from Terminal. In Terminal, navigate to the directory of the folder you d like to compress, and enter zip -r unpackaged.zip nameoffolder, where nameoffolder is the folder you re compressing. If you create a.zip file from Finder, macos changes the file structure and your compressed package will be invalid. Although you can add the same utility bar to multiple Lightning apps, we recommend assigning a utility bar to only one app. A utility bar assigned to multiple Lightning apps is shared. If you update a utility bar assigned to multiple apps, it changes across those apps. Deploy Changes to Your Org Use the Metadata API to deploy your updated package to your org. 1. In Workbench, click Migration > Deploy. 2. Click Choose File and choose unpackaged.zip, the.zip file you created. 3. Select Rollback on Error and choose an option from the Test Level dropdown. 4. Click Next, then click Deploy. 5. Wait for the page to refresh this might take a few seconds and look for success: true. And that s it! Now you can log in to your org to check it out. View the Recent Items Utility Bar in Lightning Experience In Lightning Experience, click the App Launcher and select the Lightning app you created earlier. Check that the utility bar appears at the bottom of the app, and open the Recent Items Utility. 9

View the Recent Items Utility Bar in Lightning Experience To ensure that the list of recently accessed items is populated, open a few Account record detail pages. When you open the utility, you see a list of recently viewed Accounts. 10

View the Recent Items Utility Bar in Lightning Experience To see more utilities in action, install the Discount Calculator package. To install the package, log in to Salesforce, then open a separate tab or window and navigate to https://login.salesforce.com/packaging/installpackage.apexp?p0=04tb0000000hdku. Note: To install this package, you need to have My Domain enabled. To lean more, see My Domain in the Salesforce Help. This package includes a custom utility bar with several utilities built from out-of-the-box Lightning components, and one, Discount Calculator, built with a custom Lightning component. 11