Activity Forums Salesforce® Discussions Difference Between LocalComponentId and GlobalComponentId in Salesforce Lightning?

  • Saurabh

    Member
    May 31, 2017 at 10:03 am

    Hi Suraj

    A local ID is an ID that is only scoped to the component. A local ID is often unique but it’s not required to be unique.

    Create a local ID by using the aura:id attribute. For example:

    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.
    If there are multiple components with the same local ID, find() returns an array of the components.
    If there is no matching local ID, find() returns undefined.
    To find the local ID for a component in JavaScript, use cmp.getLocalId()

    Globalid

    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.

    for more info:https://developer.salesforce.com/docs/atlas.en-us.206.0.lightning.meta/lightning/components_ids.htm

    Hope it may help

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos