How to set dynamic values in Design Data Resource of Lightning

Event propagation in lightning

Design attributes are used to set some attributes during the design time i.e. while using App builder. For example, the admin can use your component on the record detail page of a particular sObject and if any design attribute is specified in the component that attribute appears on the page. To know more about design resources, refer the link: Design resources.
If we have a component where the admin needs to set a picklist field of the sObject where the component is being used, then that can be achieved by using the datasource parameter of the attribute in the design resource. To initialize datasource we provide the path to the apex class which gets all the field values in the picklist.

The component code looks like:

And the design attribute looks like:

Notice the datasource parameter is set to the apex class which extends a standard class called VisualEditor.DynamicPickList and overrides the getValues method to return picklist values.

The apex class needed to initialize the picklist values is as follows:

Take a look at the following image:

Now when the admin select a particular value, the component will be initialized. Take a look at the following image:

Back to list

Leave a Reply

Your email address will not be published. Required fields are marked *