0

I have a VF Page Where community User (for example this user will have 3 contacts and 3 accounts, but only only for one contact community is enabled) will choose Account from drop-down list, based on the selected account when ever User initiates the chat and once Live agent accepts the chat it should create a Case record with selected Account ID and Contact info.

Currently it is creating Case record, with community User Logged in Contact details. I would like to fill with chosen account and contact details.'

Here is my Code:

Prechart Form Page:

<input type='hidden' name='liveagent.prechat:caseorigin' value='Chat'/>
        <input type='hidden' name='liveagent.prechat:caseContactId' value='{!$User.ContactId}'/>
               <input type='hidden' name='liveagent.prechat:ContactId' value='{!$User.ContactId}'/>   
        <input type='hidden' name='liveagent.prechat:contactFirstName' value='{!$User.FirstName}'/>  
        <input type='hidden' name='liveagent.prechat:contactEmail' value='{!$User.Email}'/>   
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="FirstName,contactFirstName;LastName,contactLastName;Email,contactEmail;" />    
        <!-- Try to find the Contact by email (exact match) -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact" value="Email,true;FirstName,true;" />
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Email,true;FirstName,true;" /> 

       <input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="LiveChatCategory__c,CaseCategory;LiveChatSubCategory__c,CaseSubCategory;Origin,caseorigin;ContactId,caseContactId;RecordTypeId,caseRecordType;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="LiveChatCategory__c,true;LiveChatSubCategory__c,true;Origin,true;ContactId,true;RecordTypeId,true;" />
        <!--<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Case" value="Origin,true;ContactId,true;RecordTypeId,true;" />    -->


        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case" />
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />
<br></br>
<center><input type='submit' value='CHAT' id='presubmit'/></center>

<script type='text/javascript'>
 window.onload = function(){
    var button = document.getElementById('presubmit');
    button.form.submit();
}

VF PAGE:

 <script type="text/javascript">
        if (!window._laq) { 
            window._laq = []; 
        }
        window._laq.push(
            function(){
            liveagent.showWhenOnline('{!chatbuttonid}', document.getElementById('liveagent_button_online_{!chatbuttonid}'));
            liveagent.showWhenOffline('{!chatbuttonid}', document.getElementById('liveagent_button_offline_{!chatbuttonid}'));
        }
        );
    </script>

        <script type='text/javascript' src='https://c.la2-c1cs-ph2.salesforceliveagent.com/content/g/js/46.0/deployment.js'></script>
        <script type='text/javascript'>
        liveagent.init('https://d.la2-c1cs-ph2.salesforceliveagent.com/chat', '{!deploymentId}', '{!DeployedOrgId}');
        </script> 

<apex:selectList id="Selector" size="1" styleclass="form-control" value="{!accCode}>
     <apex:selectOptions value="{!accsList}"/> <!-- This is the Account List -->
</apex:selectList> 

1 Answer 1

0

I haven't tested it but this should work.

You didn't share your controller code but you can change the getAccsList method like this:

public List<SelectOption> getaccsList() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('Account 1','0011t000008jprOAAT'));
    options.add(new SelectOption('Account 2','0011t000008jprOAAE'));
    options.add(new SelectOption('Account 3','0011t000008jprOAAQ'));

    return options;
}

and once the user submits the form, prevent default submission, grab the selected value and assign it to a new variable called selected_accountId and add it to the map:

<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value=".....AccountId,selected_accountId;"/>

and of course:

<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value=".....AccountId,true;" />

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .