Activity Forums Salesforce® Discussions What is the difference between Local IDs and Global IDs in Salesforce Lightning?

  • What is the difference between Local IDs and Global IDs in Salesforce Lightning?

    Posted by Shweta on February 25, 2020 at 12:04 pm

    What is the difference between Local IDs and Global IDs in Salesforce Lightning?

    Manish replied 4 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Manish

    Member
    February 25, 2020 at 12:49 pm

    Local IDs
    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.

    Global IDs
    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 purpose

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos