Contents
What do global IDs mean in Lightning aura?
Every component has a unique globalId, which is the generated runtime-unique ID of the component instance. A global ID (1) is not guaranteed to be the same beyond the lifetime of a component, so it should never be relied on. A global ID can be useful to differentiate between multiple instances of a component or for debugging purposes.
Find the button component by calling cmp.find (“button1”) in your client-side controller, where cmp is a reference to the component containing the button. find () returns different types depending on the result. If the local ID is unique, find () returns the component.
How to find the local ID of a component?
You can find the component by calling cmp.find (“button1”), where cmp is a reference to the component containing the button. The find () function has one parameter, which is the local ID of a component within the markup.
What are the different types of component IDs?
A component has two types of IDs: a local ID and a global ID. You can retrieve a component using its local ID in your JavaScript code. A global ID can be useful to differentiate between multiple instances of a component or for debugging purposes. A local ID is an ID that is only scoped to the component.
When to set record ID in Lightning component?
The recordId attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home.
How to get the Global ID of a component?
In your browser’s developer console, retrieve the element using document.getElementById (” _footer”) , where is the generated runtime-unique ID. To retrieve a component’s global ID in JavaScript, use the getGlobalId () function.