+ Start a Discussion
Nizam SaifiNizam Saifi 

How to get id from salesforce community URL

Hi All, I want to get id from parameter in salesforce community into apex controller but not able to get it. I tried to use ApexPages.currentPage().getParameters().get('id') but it is not working 
Hi Nizam,

If you're using API version 43 and up, you can implement lightning:isUrlAddressable interface and use pageReference attribute. A good example of this was posted here (https://salesforce.stackexchange.com/questions/165650/getting-the-url-parameter-into-lightning-component-using-the-paramname-exp). Below is a recap of the example provided:
Example - Component Assume url is https://<instance>.lightning.force.com/lightning/cmp/<namespace>__componentName?testAttribute=abc

Lightning Component:
<aura:component implements="lightning:isUrlAddressable">
   <aura:handler name="init" value="{!this}" action="{!c.doInit}" description="Handler for valueInit event fired when the component has been initialised"/>

    doInit : function(component, event, helper) {

Page Reference Types:  https://developer.salesforce.com/docs/atlas.en.us.214.0.lightning.meta/lightning/components_navigation_page_definitions.htm