I've a requirement is,When the Visitor fills in the prechat form with some basic stuff like First Name, Last Name, Email, Case Number,then "I'm trying to find that Case if not found create a new Case or display the existing Case and find  Contact,if not found create new Contact or display the existing Contact.

Below is the Code I've written,it is working for Contact creation and searching ,but not working for Case creation and finding,pls help me in this regards.

First Name: <input type='text' name='liveagent.prechat:FirstName' id='prechat_firstname' /><br />
Last Name: <input type='text' name='liveagent.prechat:LastName' id='prechat_lastname' /><br />
Email Address: <input type='Email' name='liveagent.prechat:contactEmail' /><br />
Phone Number: <input type='text' name='liveagent.prechat:PhoneNumber' /><br />
Company: <input type='text' name='liveagent.prechat:Company' /><br />
Country: <input type='text' name='liveagent.prechat:Country' /><br />
State/Province: <input type='text' name='liveagent.prechat:State/Province' /><br />
Brief Description: <input type='text' name='liveagent.prechat:BriefDescription' /><br />
Case Number: <input type='text' name='liveagent.prechat:CCaseNumber' /><br />


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

<!-- Create a Case -->
<input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat" />

<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,BriefDescription;" />
<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" />