5

I'm a newbie. I want to know that how can I provide a recorid in the url and manipulate the record in lightning component like I do in vf pages.? Can anybody help please...

4

There is an event called force:navigateToSObject

You can go to detail page of the record by providing its Id.

1

The analogous feature in lightning is URL-Centric Navigation.

Using the following as an example:

<aura:application >
    <aura:attribute name="theId" type="Id" />
    <aura:handler event="aura:locationChange" action="c.handleLocationChange"/>
    <ui:outputText value="{!v.theId}" />
</aura:application>

({
    handleLocationChange : function (component, event, helper) {
        var loc = event.getParam("token");
        console.log(loc);
        component.set("{!v.theId}",loc);
    }

})

When you navigate to your lightning application, the fragment portion of the url after the #, will be captured in the token parameter of the aura:locationChange event.

A sample url would look something like this:

<baseurl>/<YourApplicationName>.app#ASampleId
  • Can I do the same with <aura:component></aura:component> tags or this only works with <aura:application> tags? – Anas Rashid Jul 30 '16 at 6:47
  • @AnnJanu I suppose you could use it with an <aura:component> if it is a persistent component in your own application, but it won't work for components that are dynamically created (including components in Lightning Experience and Salesforce1 flexipages). – martin Aug 1 '16 at 11:04
1

I recommend you to read this documentation: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_config_for_app_builder_record_home.htm

Now you can build components for record home pages!

<aura:attribute name="recordId" type="String" />

And also you can specify the sobject type:

<aura:attribute name="sObjectName" type="String" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.