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
Phu Dang 1Phu Dang 1 

How do I get the useranme from the Communities login page and pass to a live chat method?

I have SF Communities and would like to add live chat.  In the live chat there is a method that pick up the email address.  Once it picks up the address, it will pull the contact from Salesforce.  Here is the live chat method:  SnapABug.setUserEmail('email@domain.com' (mailto:'email@domain.com')).  Since the login for SF Communities uses email address, I would like to use this email address and pass to the live chat method.  We are using the standard SF Communities webpage.  Is there a way to pass the login from the login page to the the method  above which is in the footer of the SF Communities web page.  Here is the code for the live chat that I put in the footer.
Grazitti TeamGrazitti Team
Hi Phu,

To get the user's email address of user logged in your SF community.  you can do following:

In Apex you can use: String emailAddress =  UserInfo.getUserEmail();
In VF page: {!$User.Email}


Hope this helps.

Regards,
Grazitti Team
Web: www.grazitti.com
Phu Dang 1Phu Dang 1
Which visualforce page should I use for the UserInfo.getUserEmail()?  Is it the login page, landing page ,and etc.
Grazitti TeamGrazitti Team
Hi Phu,

It will be landing page. The user must be logged in to view the userinfo details.

Let us know if you have any question. Please don't Forget to Mark this as your best answer if it works fine for you

Regards,
Grazitti Team
Web: www.grazitti.com
Phu Dang 1Phu Dang 1

  <apex:variable var="email" value="{!$User.Email}" />
  <script>

            var emailtest= document.getElementByVar('{!$Component.communitiesLandingPage.email}');

            var em = outTextComponent.innerHTML; // as output Text renderd Span element.

     </script>


Hi Grazitti Team,

This is what I put in the landing page.  Is this correct?  I want to pass the email variable from the landing page to an html page that has a Script function :  SnapABug.setUserEmail('email@domain.com' (mailto:'email@domain.com')).  I don't know how to pass the variable using javascript.  Please help.  Thank you.