0

I've got a pre-chat window, and in it I want to look for a lead and an account, and if they exist attach them to a new case. If they don't, we need to create them and then attach them to the new case.

The case is created no problems, but when I use the findOrCreate and the DoCreate tags they won't make new accounts or leads. It will find leads and accounts that exist, and those will appear in the console when the chat starts [edit:] and will attach themselves to the new Case. The following is the meat of my code...

<apex:pageblocksection >
            First Name: <input type="text" name="liveagent.prechat:FirstName"/><br/>
            Last Name: <input type="text" name="liveagent.prechat:LastName"/><br/>
            Email: <input type="text" name="liveagent.prechat:Email"/><br/>
            Phone: <input type="text" name="liveagent.prechat:phone"/><br/>
            Business Name: <input type="text" name="liveagent.prechat:accountName"/><br/>

            Subject of Chat: <input type="text" name="liveagent.prechat:caseSubject"/>
        </apex:pageblocksection>

<!-- Map the detail inputs to the Lead fields --> 
        <input type="hidden" name="liveagent.prechat:leadRecordType" value="xxxxxxxxxxxxxxx"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Lead" value="FirstName,FirstName;LastName,LastName;Email,Email;Company,accountName;RecordtypeId,leadRecordType;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Lead" value="Email,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Lead" value="Email,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Lead" value="FirstName,true;LastName,true;Email,true;Phone,true;Company,true;RecordtypeId,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Lead" value="Lead"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Lead" value="true"/>

        <!-- Do the same for an account -->
        <input type="hidden" name="liveagent.prechat:accountRecordType" value="xxxxxxxxxxxxxxxxxx"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="Name,accountName;RecordtypeId,accountRecordType;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account" value="Name,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account" value="Name,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Account" value="Name,true;RecordtypeId,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Account" value="Account"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Account" value="true"/>

        <!-- Create a Case every time and attach to transcript -->
        <input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat"/>
        <input type="hidden" name="liveagent.prechat:caseDescription" value="Initiated through pre-chat interface"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;Description,caseDescription"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true"/>

        <!-- Link the Lead + Account to the Case -->
        <input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Lead" value="Case,Lead__c"/>
        <input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Account" value="Case,AccountId"/>

The record type Ids are not normally x'd out.

Question is, where have I gone wrong trying to create these leads and accounts?

Some auxiliary info, I've tested creating these records with these values in anon apex and it allows me to, so I don't think there's a possibility that I'm running into validation or required fields.

I myself am a sysadmin so permissions shouldn't be the cause...

Thanks in advance!

[edit:] I've managed to get it to create the leads, now it's just Accounts that won't be created...

0

Check every possible spelling of field names, they will leave you wallowing otherwise.

My problem was twofold, first I didn't need a record type for a lead to be created, and second I was trying to fill in the field RecordTypeId when apparently I was meant to fill in the field RecordType. My new, every so slightly revised code follows.

<apex:pageblocksection >
            First Name: <input type="text" name="liveagent.prechat:FirstName"/><br/>
            Last Name: <input type="text" name="liveagent.prechat:LastName"/><br/>
            Email: <input type="text" name="liveagent.prechat:Email"/><br/>
            Phone: <input type="text" name="liveagent.prechat:phone"/><br/>
            Business Name: <input type="text" name="liveagent.prechat:accountName"/><br/>

            Subject of Chat: <input type="text" name="liveagent.prechat:caseSubject"/>
        </apex:pageblocksection>

        <!-- Map the detail inputs to the Lead fields --> 
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Lead" value="FirstName,FirstName;LastName,LastName;Email,Email;Company,accountName;Phone,phone;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Lead" value="Email,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Lead" value="Email,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Lead" value="FirstName,true;LastName,true;Email,true;Phone,true;Company,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Lead" value="Lead"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Lead" value="true"/>

        <!-- Do the same for an account -->
        <input type="hidden" name="liveagent.prechat:accountRecordType" value="xxxxxxxxxxxxx"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="Name,accountName;RecordType,accountRecordType;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account" value="Name,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account" value="Name,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Account" value="Name,true;RecordType,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Account" value="Account"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Account" value="true"/>

        <!-- Create a Case every time and attach to transcript -->
        <input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true"/>

        <!-- Link the Lead + Account to the Case -->
        <input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Lead" value="Case,Lead__c"/>
        <input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Account" value="Case,AccountId"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.