Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

DesignTimePageContext Class

A class that provides context information about a Lightning page. It can be used to help define the values of a picklist in a Lightning component on a Lightning page based on the page’s type and the object with which it’s associated.

Namespace

VisualEditor

Usage

To use this class, create a parameterized constructor in the custom Apex class that extends VisualEditor.DynamicPickList.

Example

Here’s an example of a custom Apex class extending the VisualEditor.DynamicPickList class. It includes VisualEditor.DesignTimePageContext to define a picklist value that is available only if the page type is HomePage.

1global class MyCustomPickList extends VisualEditor.DynamicPickList{
2    VisualEditor.DesignTimePageContext context;
3
4    global MyCustomPickList(VisualEditor.DesignTimePageContext context) {
5       this.context = context;
6    }
7
8    global override VisualEditor.DataRow getDefaultValue(){
9        VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('red', 'RED');
10        return defaultValue;
11    }
12    global override VisualEditor.DynamicPickListRows getValues() {
13        VisualEditor.DataRow value1 = new VisualEditor.DataRow('red', 'RED');
14        VisualEditor.DataRow value2 = new VisualEditor.DataRow('yellow', 'YELLOW');
15        VisualEditor.DynamicPickListRows  myValues = new VisualEditor.DynamicPickListRows();
16        myValues.addRow(value1);
17        myValues.addRow(value2);
18
19        if (context.pageType == 'HomePage') {
20            VisualEditor.DataRow value3 = new VisualEditor.DataRow('purple', 'PURPLE');
21            myValues.addRow(value3);
22        }
23
24        return myValues;
25    }
26}

DesignTimePageContext Properties

The following are properties for DesignTimePageContext.

entityName

The API name of the sObject that a Lightning page is associated with, such as Account, Contact, or Custom_object__c. entityName is available only for object pages, and not all Lightning pages are associated with objects.

Signature

public String entityName {get; set;}

Property Value

Type: String

pageType

The type of Lightning page, such as HomePage, AppPage, or RecordPage.

Signature

public String pageType {get; set;}

Property Value

Type: String

DesignTimePageContext Methods

The following are methods for DesignTimePageContext.

clone()

Makes a duplicate copy of the VisualEditor.DesignTimePageContext object.

Signature

public Object clone()

Return Value

Type: Object