The Story

We have built a Lightning Component that can be put in a FlexiPage and shows the Name of a Field of the Object it's on. It has a Designer and in it a Picklist to choose the Field to be shown.

The Component

<aura:component implements="forceCommunity:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:appHostable,force:lightningQuickAction" access="global" >
    <aura:attribute name="fieldName"            type="String"           default="Id"    access="global" />

The Designer

    <design:attribute   name="fieldName"        label="Field to display:"       datasource="apex://designerController"  />

In order to get the Fields dynamically we have written an Apex Class named "designerController".

Apex Class

global class designerController extends VisualEditor.DynamicPicklist {
    VisualEditor.DesignTimePageContext context;
    global designerController(VisualEditor.DesignTimePageContext context) {
        this.context = context;
    global override VisualEditor.DataRow getDefaultValue(){
        VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('Id','Id');
        return defaultValue;
    global override VisualEditor.DynamicPickListRows getValues() {
        VisualEditor.DynamicPickListRows values = new VisualEditor.DynamicPickListRows();
        sObjectType entity = Schema.getGlobalDescribe().get(context.entityName);
        Map<String, Schema.SObjectField> fields = entity.getDescribe().fields.getMap();
        Set<String> objFields = fields.keySet();
        for(String field : objFields) {
            VisualEditor.DataRow value = new VisualEditor.DataRow(field, field);
        return values;

This works fine!

  • The Component recognizes the Object
  • You can choose the desired Field in the Lightning App Builder
  • The Name displays

Lightning App Builder

The Problem: Managed Package

Uploading the Component, Designer, Apex Class and Flexipage into the Managed Package works also as intended. The problem arises when we try to install the Package. Then we get the following error on the target-org:

TestObject_Record_Page: Invalid datasource. Encountered runtime exception in Apex class: [designerController]

And the Package doesn't get installed...


We have already tried some Workarounds. First, we tried adding the Namespace to the attribute in the Designer, but it didn't fix it. Then we tried erasing the "datasource" in the design:attribute Tag. We installed the Package and it worked. After this we reuploaded the Package, this time adding the "datasource" to the design:attribute Tag. Finally, we installed it on more time and it worked. However, this is not feasible as we will be installing this Package on several orgs. We need a solution for installing this Package as any other and get the desired outcome.

  • Have you tried adding a namespace to the datasource as: datasource="apex://namespace.designerController". It says its a known issue and fixed, but apparently not
    – Raul
    Commented Jan 26, 2022 at 15:40


You must log in to answer this question.