Tag Archives: Community Page

Get Salesforce Community Page URL Parameters in Lightning Component

Community URL:
https://testcommunity.my.salesforce.com/communityname/ProfilePage?id=00Q0I00000xUjMH&name=biswajeet

Lightning JS Controller:

({
    getParamValue: function(component, event, helper) {

        //Get Id Parameter Value From Community URL
        var idParamValue = helper.getURLParameterValue().id;
        console.log('Id-' + idParamValue);

        //Get Name Parameter Value From Community URL
        var nameParamValue = helper.getURLParameterValue().name;
        console.log('Name-' + nameParamValue);
    }
})

Lightning JS Helper:

({
    getURLParameterValue: function() {

        var querystring = location.search.substr(1);
        var paramValue = {};
        querystring.split("&").forEach(function(part) {
            var param = part.split("=");
            paramValue[param[0]] = decodeURIComponent(param[1]);
        });

        console.log('paramValue-' + paramValue);
        return paramValue;
    }
})