function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kevin DyerKevin Dyer 

Adding an onclick function to go to url in javascript Salesforce Communities

I am using this JavaScript to display a hyperlink. When I click the link, I am not taken anywhere. Could you please let me know why that might be? 

<script >
    //get survey link
    function goSurvey() {
        var param = '';
        var url = document.URL;

        var match = /(\/article\/)(.*)/g.exec(url);
        if(match!=null) {
            var param = match[2];
        }
        var fname = '{!CurrentUser.firstName}';
        var lname = '{!CurrentUser.lastName}';
        var email = '{!CurrentUser.email}'; {!

        var link = 'http://survey.medallia.com/articlefeedback?u=' + param + '&e=' + email + '&f=' + fname + '&l=' + lname;
        window.open(link);
    };
</script>

<center> 
    <a id="articleFeedback" title="Rate this article" href="#" onclick="goSurvey();return false;">Rate this article</a> 
</center>
SarfarajSarfaraj
Kevin,

Use this 
var fname = '{!$User.firstName}';
var lname = '{!$User.lastName}';
var email = '{!$User.email}';
Instead of this,
var fname = '{!CurrentUser.firstName}';
var lname = '{!CurrentUser.lastName}';
var email = '{!CurrentUser.email}';
--Akram