• Atul Gupta 46
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

We have implemented the live Agent functionality in Production. We have also our portal users for whome this chat functionality provided. Through portal home page , clients can initiate chat (chat button provided on portal). Also we have implemented the Prechat form in order to receive the data like Name, email, Account..

 

This is working fine but clients needs to fill out these details in Prechat form, which is not feasible since they are Portla users. So I am prepopulating these details like name, email in Pre chat form. Used prety simple code at VF (mentioned below) , this is working fine in Salesforce preview. However, when used on Portal , prechat form is not reflecting the correct Name , email in Pre chat form. In the name field this is reflecting Sitename and in email email this is using the by default site user email id.

 

We want when, every client logged in Portal and initiating the chat , in prechat form , Client name and email should be in user context....

 

Please let me know any workaround / solution how to resolve this.

 

I will really appreciate this ....

 

<apex:page showHeader="false" standardController="User" >

    <script>
        function clickBtn()
        {
            var btnSubmit = document.getElementById('prechat_submit');
            btnSubmit.click();
        }
    </script>

    <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
    <script type="text/javascript">
        (function()
        {
            function handlePageLoad()
            {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
                document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
            }
            if (window.addEventListener)
            {
                window.addEventListener('load', handlePageLoad, false);
            }
            else
            {
                window.attachEvent('onload', handlePageLoad, false);
            }
        })();
    </script>
   
    <h1>Pre-chat Form</h1>
    <form method='post' id='prechatForm'>
   
        <style type="text/css">
            body {
                margin: 0 auto;
                padding: 0;
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
                font-size: 12px;
                color: #737373;
                line-height: 16px;
            }                   

            p {
                font-weight: bolder
            }
           
            td {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }
           
            h1 {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }

            .btnClass {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }

        </style>

        <!-- Creates an auto-query for a matching Contact record’s Email field based on the value of the liveagent.prechat:Email field -->   
        <table border="0" width="400px">
            <tr>
                <td>
                    <b>Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' />          
                </td>
            </tr>
            <tr>
                <td>
                    <b>Email Address: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />
                </td>
            </tr>
            <tr>
                <td>
                    <b>Property Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Account' value='{!getAccountName}' />
                </td>
            </tr>
            <tr>
                <td>
                   
                </td>
                <td align="center">
                    <input type='submit' value='Request Chat' id='prechat_submit' class="btnClass" />
                </td>
            </tr>
        </table>

        <input type="hidden" name="liveagent.prechat.query:Email" value="Contact,Contact.Email" />        

    </form>


</apex:page>

 

Thanks alot !!!!