Explore Template Structure
Learning Objectives
The CEO Raises the Bar
After completing the last unit, you’re jazzed to show the CEO how the new template works. (OK, you didn’t really do much since we made the template, but for now, let’s pretend you did.) So you take the CEO through the app creation process and show her the dashboards in the app, the Sales Performance and Pipeline Performance executive overviews.
The CEO is suitably appreciative, but she wants more. (Of course she does!) “Since we talked last, I found out some of our partners use Service Cloud and want that Service Performance dashboard, too. I want to make it real easy—we don’t want to give anyone a single reason not to love us. Can we give them the option of adding that dashboard?
“Also, turns out some of our partners are picky, picky, picky. I was using the dashboards during our weekly call, and a few folks hoped they could look at different data. A couple of them asked about different ways of showing where their accounts are located. And someone else mentioned they don’t track new business the way we do.”
Just to be sure you know what she’s talking about, you open the app and ask her to show you.
She says, “See Billing Country? Some of our smaller partners want to view that by state or city. And see Lead Source? That shows how we get new business, but lots of our partners don’t use the same terminology. Can you change that?”
Fortunately, you’ve reviewed the CRM Analytics Templates Developer Guide and you already know the solution: Edit the template to add a configuration wizard with questions that let users customize their versions of the app. Remember, Execs Only 1 is a plain vanilla version of the exec app, with no variations possible.
Before you can edit the template, you need to understand what’s in it. In this unit, we run through the template files to show you how they control the template and, ultimately, the app you create from it.
Template JSON Files
When you create a template from a CRM Analytics app, you get a directory of files that looks like this.
It includes the JSON files that make up the template object. They define dashboards, datasets ( external_files), and recipes or dataflows. It also includes the files you edit to add the wizard and other functionality. Note that these files are only available when you retrieve the metadata after creating the template. To learn more about that, follow the link to Retrieve (Export) the WaveTemplate Object from the CRM Analytics Templates Developer Guide in the Resources section at the end of this unit.
- template-info.json manages all elements of your template, including metadata information about the template, the CRM Analytics objects that define dashboards and lenses, and the other files that are part of the template.
- ui.json manages the configuration wizard that drives app creation. It defines the number of wizard pages, the order of wizard questions, and any messages you want the user to see.
- variables.json contains all template variables, including the text for wizard questions and specifications for the answers. Variables also define conditional questions. For example, you may want some questions to appear in the wizard only if an org contains certain data. Or you might want to add more specific questions based on the answers to more general wizard questions.
- template-to-app-rules.json defines the rules the template follows. For example, you could define a rule that specifies that if an org doesn’t use certain Salesforce objects, the app won’t refer to them in dashboards or include them in the dataflow. Rules also define how variables are handled. For example, if the wizard asks which fields to include in filters for accounts, template-to-app-rules.json determines how that choice is reflected in dashboards. Note: We abbreviate the name of this file to rules.json in the rest of this module for ease of reading.
- folder.json organizes the parts of dashboards, for example letting you set the order of dashboards in an app instead of keeping them in alphabetical order.
If you have sharp eyes, you might have noticed a JSON file for our missing Service Performance dashboard ( Exec_Overview_Service_Performance.json). We’ll come back to that a little later.
Meet The Boss: template-info.json
Let’s look at those files from Execs Only Template 1, starting with template-info.json.
{ "assetVersion" : 41, "name" : "Trailhead_Template_PartOne", "releaseInfo" : { "templateVersion" : "4.0" }, //1-THE DASHBOARDS "dashboards" : [ { "file" : "dashboard/Exec_Overview_Pipeline_Performance.json", "name" : "Exec_Overview_Pipeline_Performance_PartOne", "label" : "Exec Overview - Pipeline Performance" }, { "file" : "dashboard/Exec_Overview_Sales_Performance.json", "name" : "Exec_Overview_Sales_Performance_PartOne", "label" : "Exec Overview - Sales Performance" } ], //2-TEMPLATE DESCRIPTION "description" : "Unlock the power of Analytics Templates.", "eltDataflows" : [ { "file" : "workflow/SalesAnalyticsDataflow.json" } ], //3-THE DATASETS "datasetFiles" : [ { "label" : "Users", "name" : "user_PartOne" }, { "label" : "Opportunities", "name" : "opportunity_PartOne", "userXmd" : "external_files/opportunity_XMD_template.json" }, { "label" : "User Allocation", "name" : "quota_PartOne", "userXmd" : "external_files/quota_XMD_template.json" }, { "label" : "Pipeline Trending", "name" : "pipeline_trending_PartOne", "userXmd" : "external_files/pipeline_trending_XMD_template.json" } ], "externalFiles" : [ { "file" : "external_files/plain_quota.csv", "name" : "plain_quota_PartOne", "schema" : "external_files/plain_quota.json", "type" : "CSV" } ], //4-THE TEMPLATE NAME "label" : "Execs Only Template 1", //5-REFERENCES TO OTHER FILES "folderDefinition" : "folder.json", "rules" : [ { "type" : "templateToApp", "file" : "template-to-app-rules.json" } ], "uiDefinition" : "ui.json", "variableDefinition" : "variables.json", "icons" : { "appBadge" : { "name" : "16.png" }, "templateBadge" : { "name" : "trailhead_icon_160x160" }, "templateDetail" : { "name" : "trailhead_detail" } } }
Variables, UI, and Rules
Let’s take a close look at the other template object files, starting with variables.json.
{ //1-THE DEFAULT VARIABLE "variableType": { "type": "ObjectType", "properties": { "createAllDashboards": { "type": "BooleanType" } }, //2-THE OVERRIDE "Overrides": { "required": true, "description": "Internal configuration to allow asset creation overrides, not to be displayed in UI.", "defaultValue": { "createAllDashboards": false }, "strictValidation": true } } }
The file contains a single default variable (1) for creating all assets, that is createAllDashboards.
It also includes an override (2), which is set to false. This means that if we want the template to create any dashboards other than the ones referred to in template_info.json—namely our missing Service Performance dashboard—we have to explicitly say so. Keep that in mind for now—we show what to do about that soon.
Next, let’s examine ui.json. The file determines the contents of the configuration wizard. Execs Only 1 doesn’t have a wizard, so there’s nothing in the file—its default condition.
{ "pages": [ ] }
Finally, here’s the Execs Only 1 rules.json file, also empty by default. Since users can’t make any choices from wizard questions, there are no rules for how to change dashboards. Notice that there are two sections: constants and rules. We’ll say more about those later.
{ "constants": [], "rules": [] }
To give the CEO—and our partners—what they want, we’re going to edit all 4 files. We show you how that’s done in the next two units. But first, a few more questions to help you earn your badge for this module.
Resources
- Retrieve (Export) the WaveTemplate Object
- The Template Object
- Download the code for this module. The download includes two files: EATP1 contains the basic Template 1, which you used to create the basic app. EATP2 contains Template 2, which includes the JSON modifications we describe in this and the next modules.