function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gonzalo Quevedo 15Gonzalo Quevedo 15 

Using {!v.objectName} in Lightning component Design file

Hi!

I am working in a lighning component. This component will be displayed in lightning app builder interface, so users will be able to put it in ANY object record page.

I use some attributes (for component configuration) in the design file. Some of them are picklist that I populate in an apex class. This picklist values should change depending on the object that use my component. Is there any way to know in which object the component is running? I know I can use {!v.objectName}  in component markup but I don't know if is possible to do something similar at design file or the apex class that I use to show my custom picklist values for my picklist attribute.

Thanks! :)
Best Answer chosen by Gonzalo Quevedo 15
Gonzalo Quevedo 15Gonzalo Quevedo 15
Thanks for the trailhead reference, I found iy very useful but It diden't solve my problem.

I resolve my problem with this: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_VisualEditor_DesignTimePageContext.htm#apex_class_VisualEditor_DesignTimePageContext

Very handy! . 
 

All Answers

Alain CabonAlain Cabon
Hi,

There is a new great new project with a technique using the metadata for components working for any object:   

Build Reusable Lightning Components:

Build Lightning components for any object, with the help of custom metadata and Apex: Prepare to Be Object-Agnostic

https://trailhead.salesforce.com/en/projects/build-reusable-lightning-components
 
Alain CabonAlain Cabon
The new custom metadata objects to be precise (not to be confused with the well-known metadata generally speaking).
Gonzalo Quevedo 15Gonzalo Quevedo 15
Thanks for the trailhead reference, I found iy very useful but It diden't solve my problem.

I resolve my problem with this: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_VisualEditor_DesignTimePageContext.htm#apex_class_VisualEditor_DesignTimePageContext

Very handy! . 
 
This was selected as the best answer