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
Morgan MarcheseMorgan Marchese 

LiveAgent findOrCreate.map.isExactMatch - open more than one (different) object subtabs? Having Problems

I am working on a PreChat VisualForce page. On that page, the customer enters the following info into the perchat form:
First Name (FirstNameDetail), Last Name(LastNameDetail), Email(EmailDetail), and Customer Number (CustomerNumber).

I am trying to do 2 separate isExactMatch hidden fields:
  1. Open the Account if CustomerNumber in the form is an exact match to Customer_Number__c custom field on Account
  2. Open the Contact if EmailDetail in the form is an exact match to Email on Contact AND the CustomerNumber field in the form is an exact match to the Customer_Number__c field on the Contact.
Note: The Customer_Number__c field on the Contact is a text based Formula field that just displays 'Account.Customer_Number__c' on each Contact Record.

I know that INDIVIDUALLY, each of my ExactMatches work. I know this because I tested the Account ExactMatch by itself by removing the Contact ExactMatch from the page, and I also did the reverse and tested the Contact ExactMatch by removing the Account ExactMatch. In each scenario, the Account or Contact record was successfully opened as an Exact Match in a subtab in the console. However, when adding both together to the page, it doesn't open 2 sub-tabs as I'm hoping it would.

Desired Result:
  1. If Customer Number matches on the Account but Email/Customer Number doesn't match on the contact - I want to load the Account Page only.
  2. If Customer Number matches on Account AND Email/Customer Number on Contact matches, I want to have the Account Page AND the Contact Page loaded as 2 separate sub-tabs within the Service Console window for the live agent session.

Current Result:
Right now with my current implementation, desired result #1 works as expected. I enter a customer number and an incorrect email, and it loads up the correct account and no contact record.
However, desired result #2 is not working as expected. If I enter a customer number and a CORRECT email of a contact linked to that account, it loads up a Search Results page that displays the Account and the Contact, rather than loading the account and contact into their own subtabs, as seen in the screenshot below:
User-added image
My desired result is that when it exact matches all criteria, it opens up the Account in a Subtab, and the Contact in another subtab, instead of just giving me a search results page like I'm getting now.

Reason:
The reason I am doing this is because in our specific Salesforce Instance, it is possible for a contact to exist more than once with the same email address, but under different accounts, because one contact may own or operate multiple accounts. Each of our accounts is identified by a unique number called Customer Number, and so I need to match for contacts of THAT specific account, rather than just contacts as a whole. If I limit myself to searching only Email, I could end up with 20+ different contact results of the same person on 20+ different accounts.

Code:
<apex:page showHeader="false"> 
<!-- CSS and SCRIPTS removed to save space on Dev Forum Post-->
<div>
    <form method='post' id='prechatForm'> 
        <table class="formTable">
            <tr>
                <td><b>First Name:</b></td>
                <td><input type='text' name='liveagent.prechat:FirstNameDetail' /> </td>
            </tr>
            <tr>
                <td><b>Last Name:</b></td>
                <td><input type='text' name='liveagent.prechat:LastNameDetail' /></td>
            </tr>
            <tr>
                <td><b>Email Address:</b></td>
                <td><input type='text' name='liveagent.prechat:EmailDetail' /></td>
            </tr>
            <tr>
                <td><b>Customer Number:</b></td>
                <td><input type='text' name='liveagent.prechat:CustomerNumber' /></td>
            </tr>
            <tr><td>&nbsp;</td></tr>
            <tr>
                <td><b>Department:</b></td>
                <td>
                        <select name="liveagent.prechat.buttons">
                        <!-- Values are LiveChatButton IDs. -->
                        <option value="573U0000000TTKV">ABC Support</option>
                        <option value="573U0000000TTzY">XYZ Support</option>
                        <!--<option value="573U0000000TTzY,573U0000000TTKV">XYZ Support If Available,
                        otherwise ABC Support</option>-->
                        </select>
                </td>
            </tr>
            <tr><td>&nbsp;</td></tr>
            <tr>
                <td><input type='submit' value='Start Chat' id='prechat_submit'/></td>
            </tr>
        </table>

<!--Save Email Address to Chat Transcript-->
<input type="hidden" name="liveagent.prechat.save:EmailDetail" value="Email__c" />
<!--Save Customer Number to Chat Transcript-->
<input type="hidden" name="liveagent.prechat.save:CustomerNumber" value="Customer_Number__c" />

<!--POP OUTS-->

    <!-- ACCOUNT -->
        <!--Map To an Account if CustomerNumber variable in form equals Customer_Number__c custom field on account -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Account"
        value="Customer_Number__c,CustomerNumber" />
        
        <!--doFind where Customer_Number__c match = true -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account"
        value="Customer_Number__c,true" />
        
        <!--Open the Account when we find an Exact Match -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account"
        value="Customer_Number__c,true" />

    <!-- CONTACT -->
        <!--Map to a Contact if CustomerNumber variable and EmailDetail variable in form match to Customer_Number__c and Email field on contact-->
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Contact"
        value="Customer_Number__c,CustomerNumber;Email,EmailDetail" />
        
        <!--doFind where Customer_Number__c match = true and Email match = true -->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact"
        value="Customer_Number__c,true;Email,true" />
        
        <!--Open the Contact whne we find an Exact Match-->
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact"
        value="Customer_Number__c,true;Email,true" />

</form> 
</div>
</apex:page>


I've been racking my brain on this all morning and not getting any farther - could use some extra brain power from the community. All thoughts and input appreciated. Thanks!
Andy BoettcherAndy Boettcher
Morgan,

This is a great post - very informative and has all of the information anyone would need to help you.  Unfortunately, it looks like no one that is surfing the boards in the last ~2 weeks has any experience in this area.  Were you able to make any headway on this in the meantime?
Morgan MarcheseMorgan Marchese
Hi Andy,

Thanks for taking the time to reply even if just to check in on my progress. Always great to see MVPs acknowledging good posts, thank you. I see that you also replied to my other (less lengthy) post where I made a similar inquiry based on other attempts to use doFind as well as isExactMatch. Unfortunately it appears that my results never change. I'm always able to get one result to pop up if I remove the other 2, but introducing even one (or both) of the other doFinds results in a Search Results page rather than individually opening each record in a new tab.

Still unsure if this is expected functionality or if there is some way to work around this concept, but I can appreciate that not everyone uses Live Agent and of those who do not everyone will be using the prechat findorcreate functionality to the extent that I am trying to.

So far, I've accepted that for the time being until I become a more seasoned developer that this is the way of it. If you have any suggestions or know of any others who may have experience, feel free to point them my way!
Sonal Dixit 8Sonal Dixit 8
Hi Morgan,

Were you able to find the solution for this?