• Mohan N 17
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
Hi All,
I implemented Email services for Inbound Emails.
When a user sends a mail to company mail case has to be created and that mail has to attached in Email related list,if any attachments consists those need to attach in attachments.
Here everything is going well but my issue is when we reply to mail from salesforce case to user who sends the email mail is going to users mail but when user sends a reply to that mail which is comes from salesforce case the reply is not attaching to salesforce case email related list instead of these it is showing in Activities.
Please help to solve this I'm attaching my code below
<
global class CareServiceClass implements Messaging.InboundEmailHandler 
 {

   global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
   {
       Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
       Set<String> Restrictedset = new Set<String>();
        for(Restricted_Keywords__c rr : Restricted_Keywords__c.getall().values())
        {
          Restrictedset.add(rr.Restricted_Keyword_or_Email__c);
         }
       id CaseRectyid = [select id,name,DeveloperName,SobjectType from recordtype where SobjectType = 'Case' and DeveloperName = 'Order_Support'].id;
       id CaseRectyLeadid = [select id,name,DeveloperName,SobjectType from recordtype where SobjectType = 'Case' and DeveloperName = 'Lead'].id;
       id Caseownerid = [select Id from Group where Name = 'IB_EmailToCase team' and Type = 'Queue'].id;
             if(!(Restrictedset.contains(email.fromAddress )  ) )
               {             
                       case c = new case ();
                       c.status= 'Open' ;
                       c.Origin= 'Email' ;
                       c.Priority= 'Email' ;
                     c.Ownerid=Caseownerid ;
                     
                       if(Restrictedset.contains(email.subject))
                       {
                       c.Type = 'Lead';
                       c.Recordtypeid= CaseRectyLeadid;
                       }
                       else{
                       c.Type = 'Order Support';
                       c.Recordtypeid= CaseRectyid ;
                       }
                       c.subject = email.subject;
                       c.Description = email.plainTextBody;
                        
                     //  c.ContactEmail = email.From;
                       insert c;
                       //system.debug('owner'+c);
                       
                     
                    EmailMessage[] newEmail = new EmailMessage[0];
                    newEmail.add(new EmailMessage(FromAddress = email.fromAddress, FromName = email.fromName, ToAddress = email.toAddresses[0], Subject = email.subject,
                         TextBody = email.plainTextBody, HtmlBody = email.htmlBody,ParentId = c.Id,status='0',Incoming=true));   
                    insert newEmail;  
                     
                   List<Attachment> attachmentList = new List<Attachment>();
                      if(email.binaryAttachments != null && !email.binaryAttachments.isEmpty()){
                          system.debug('--- email.binaryAttachments ---'+email.binaryAttachments.size());
                          for(Messaging.InboundEmail.BinaryAttachment bAttach : email.binaryAttachments){
                              Attachment attach = new Attachment();
                              attach.ParentId = c.id;
                              attach.Body = bAttach.body;
                              attach.Name = bAttach.fileName;
                              attachmentList.add(attach);
                          }
                      }
                      
                      if(email.textAttachments != null && !email.textAttachments.isEmpty()){
                         system.debug('--- email.textAttachments ---'+email.textAttachments.size());
                          for(Messaging.InboundEmail.TextAttachment tAttach : email.textAttachments){
                              Attachment attach = new Attachment();
                              attach.ParentId = c.id;
                              attach.Body = Blob.valueOf(tAttach.body);
                              attach.Name = tAttach.fileName;
                              attachmentList.add(attach);
                          }
                      }
                      
                if(!attachmentList.isEmpty())
                          insert attachmentList;
   
                
         }  
         result.success = true;
         return result;
            
     }

}
Hi,

I'm implementing live agent by using prechat form url and getting an error as Connection Lost: Please check your local connection.
If I tried without prechat form url I'm not getting error & I'm not getting any ideas can anyone help for this bcoz we are in last date for our project.
I placed my url in 
chat button configuration-->prechat form url field in salesforce.
my button,deployment code is:
<html>    
<body>

<h3>Chat</h3>
<p>
    <!-- Button code starts -->
<a id="liveagent_button_online_573p00000004C98" href="javascript://Chat" style="display: none;" onclick="liveagent.startChat('573p00000004C98')">Support Enquiry</a>
<div id="liveagent_button_offline_573p00000004C98" style="display: none;">Sorry! currently we are offline. <br/>please,write us at care@industrybuying.com</div>
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573p00000004C98', document.getElementById('liveagent_button_online_573p00000004C98'));
liveagent.showWhenOffline('573p00000004C98', document.getElementById('liveagent_button_offline_573p00000004C98'));
});</script>
    <!-- Deployment code starts -->
<script type='text/javascript' src='https://c.la9cs.salesforceliveagent.com/content/g/js/35.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la9cs.salesforceliveagent.com/chat', '572p00000004C98', '00Dp00000000Pj8');
</script>

</body>
</html>

My prechat form is:
<!DOCTYPE html>
<html>
<head>
<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>
</head>
<body bgcolor="#f3f3f3">
<div id="chatFormDiv" float="left" align="center">
     <span id="chatHeader">Please fill the following details to start Chat</span><br/>
    <hr color="#000"/>
<form method="post" id="prechatForm" align="middle">
<!-- Detail inputs -->
    
    Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactLastName" required="required"/><br /><br />
    Email &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactEmail" required="required"/><br /><br />
    Phone &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactPhone" /><br /><br />
    Subject &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:caseSubject" /><br /><br />
  
<input type="hidden" name="liveagent.prechat.buttons" value="true" />

<!-- Map the detail inputs to the Contact fields --> 
<input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="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;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Email,true;" />

<!-- If the Contact is not found, then create one with the following fields set -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Contact" value="LastName,true;Email,true;" />

<!-- Save the Contact on the Live Chat Transcript's Contact Loookup -->
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Contact" value="Contact" />

<!-- Show the Contact when it is found or created -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />

<!-- Create a Case every time -->
<input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat" />
<input type="hidden" name="liveagent.prechat:caseRecordType" value="Live Chat" />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;RecordType,caseRecordType;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;RecordType,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 Contact to the Case -->
<input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Contact" value="Case,ContactId" />

<input type="submit" value="Start Chat" id="prechat_submit"/> 

</form> 
</div>
</body>
</html>

Thanks
Mohan.
Hi,

I'm implementing live agent by using prechat form url and getting an error as Connection Lost: Please check your local connection.
If I tried without prechat form url I'm not getting error & I'm not getting any ideas can anyone help for this bcoz we are in last date for our project.

my button,deployment code is:
<html>    
<body>

<h3>Chat</h3>
<p>
    <!-- Button code starts -->
<a id="liveagent_button_online_573p00000004C98" href="javascript://Chat" style="display: none;" onclick="liveagent.startChat('573p00000004C98')">Support Enquiry</a>
<div id="liveagent_button_offline_573p00000004C98" style="display: none;">Sorry! currently we are offline. <br/>please,write us at care@industrybuying.com</div>
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573p00000004C98', document.getElementById('liveagent_button_online_573p00000004C98'));
liveagent.showWhenOffline('573p00000004C98', document.getElementById('liveagent_button_offline_573p00000004C98'));
});</script>
    <!-- Deployment code starts -->
<script type='text/javascript' src='https://c.la9cs.salesforceliveagent.com/content/g/js/35.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la9cs.salesforceliveagent.com/chat', '572p00000004C98', '00Dp00000000Pj8');
</script>

</body>
</html>

My prechat form is:
<!DOCTYPE html>
<html>
<head>
<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>
</head>
<body bgcolor="#f3f3f3">
<div id="chatFormDiv" float="left" align="center">
     <span id="chatHeader">Please fill the following details to start Chat</span><br/>
    <hr color="#000"/>
<form method="post" id="prechatForm" align="middle">
<!-- Detail inputs -->
    
    Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactLastName" required="required"/><br /><br />
    Email &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactEmail" required="required"/><br /><br />
    Phone &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactPhone" /><br /><br />
    Subject &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:caseSubject" /><br /><br />
  
<input type="hidden" name="liveagent.prechat.buttons" value="true" />

<!-- Map the detail inputs to the Contact fields --> 
<input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="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;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Email,true;" />

<!-- If the Contact is not found, then create one with the following fields set -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Contact" value="LastName,true;Email,true;" />

<!-- Save the Contact on the Live Chat Transcript's Contact Loookup -->
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Contact" value="Contact" />

<!-- Show the Contact when it is found or created -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />

<!-- Create a Case every time -->
<input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat" />
<input type="hidden" name="liveagent.prechat:caseRecordType" value="Live Chat" />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;RecordType,caseRecordType;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;RecordType,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 Contact to the Case -->
<input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Contact" value="Case,ContactId" />

<input type="submit" value="Start Chat" id="prechat_submit"/> 

</form> 
</div>
</body>
</html>

Thanks
Mohan.
Hi All,
I implemented Email services for Inbound Emails.
When a user sends a mail to company mail case has to be created and that mail has to attached in Email related list,if any attachments consists those need to attach in attachments.
Here everything is going well but my issue is when we reply to mail from salesforce case to user who sends the email mail is going to users mail but when user sends a reply to that mail which is comes from salesforce case the reply is not attaching to salesforce case email related list instead of these it is showing in Activities.
Please help to solve this I'm attaching my code below
<
global class CareServiceClass implements Messaging.InboundEmailHandler 
 {

   global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
   {
       Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
       Set<String> Restrictedset = new Set<String>();
        for(Restricted_Keywords__c rr : Restricted_Keywords__c.getall().values())
        {
          Restrictedset.add(rr.Restricted_Keyword_or_Email__c);
         }
       id CaseRectyid = [select id,name,DeveloperName,SobjectType from recordtype where SobjectType = 'Case' and DeveloperName = 'Order_Support'].id;
       id CaseRectyLeadid = [select id,name,DeveloperName,SobjectType from recordtype where SobjectType = 'Case' and DeveloperName = 'Lead'].id;
       id Caseownerid = [select Id from Group where Name = 'IB_EmailToCase team' and Type = 'Queue'].id;
             if(!(Restrictedset.contains(email.fromAddress )  ) )
               {             
                       case c = new case ();
                       c.status= 'Open' ;
                       c.Origin= 'Email' ;
                       c.Priority= 'Email' ;
                     c.Ownerid=Caseownerid ;
                     
                       if(Restrictedset.contains(email.subject))
                       {
                       c.Type = 'Lead';
                       c.Recordtypeid= CaseRectyLeadid;
                       }
                       else{
                       c.Type = 'Order Support';
                       c.Recordtypeid= CaseRectyid ;
                       }
                       c.subject = email.subject;
                       c.Description = email.plainTextBody;
                        
                     //  c.ContactEmail = email.From;
                       insert c;
                       //system.debug('owner'+c);
                       
                     
                    EmailMessage[] newEmail = new EmailMessage[0];
                    newEmail.add(new EmailMessage(FromAddress = email.fromAddress, FromName = email.fromName, ToAddress = email.toAddresses[0], Subject = email.subject,
                         TextBody = email.plainTextBody, HtmlBody = email.htmlBody,ParentId = c.Id,status='0',Incoming=true));   
                    insert newEmail;  
                     
                   List<Attachment> attachmentList = new List<Attachment>();
                      if(email.binaryAttachments != null && !email.binaryAttachments.isEmpty()){
                          system.debug('--- email.binaryAttachments ---'+email.binaryAttachments.size());
                          for(Messaging.InboundEmail.BinaryAttachment bAttach : email.binaryAttachments){
                              Attachment attach = new Attachment();
                              attach.ParentId = c.id;
                              attach.Body = bAttach.body;
                              attach.Name = bAttach.fileName;
                              attachmentList.add(attach);
                          }
                      }
                      
                      if(email.textAttachments != null && !email.textAttachments.isEmpty()){
                         system.debug('--- email.textAttachments ---'+email.textAttachments.size());
                          for(Messaging.InboundEmail.TextAttachment tAttach : email.textAttachments){
                              Attachment attach = new Attachment();
                              attach.ParentId = c.id;
                              attach.Body = Blob.valueOf(tAttach.body);
                              attach.Name = tAttach.fileName;
                              attachmentList.add(attach);
                          }
                      }
                      
                if(!attachmentList.isEmpty())
                          insert attachmentList;
   
                
         }  
         result.success = true;
         return result;
            
     }

}
Hi,

I'm implementing live agent by using prechat form url and getting an error as Connection Lost: Please check your local connection.
If I tried without prechat form url I'm not getting error & I'm not getting any ideas can anyone help for this bcoz we are in last date for our project.

my button,deployment code is:
<html>    
<body>

<h3>Chat</h3>
<p>
    <!-- Button code starts -->
<a id="liveagent_button_online_573p00000004C98" href="javascript://Chat" style="display: none;" onclick="liveagent.startChat('573p00000004C98')">Support Enquiry</a>
<div id="liveagent_button_offline_573p00000004C98" style="display: none;">Sorry! currently we are offline. <br/>please,write us at care@industrybuying.com</div>
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573p00000004C98', document.getElementById('liveagent_button_online_573p00000004C98'));
liveagent.showWhenOffline('573p00000004C98', document.getElementById('liveagent_button_offline_573p00000004C98'));
});</script>
    <!-- Deployment code starts -->
<script type='text/javascript' src='https://c.la9cs.salesforceliveagent.com/content/g/js/35.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la9cs.salesforceliveagent.com/chat', '572p00000004C98', '00Dp00000000Pj8');
</script>

</body>
</html>

My prechat form is:
<!DOCTYPE html>
<html>
<head>
<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>
</head>
<body bgcolor="#f3f3f3">
<div id="chatFormDiv" float="left" align="center">
     <span id="chatHeader">Please fill the following details to start Chat</span><br/>
    <hr color="#000"/>
<form method="post" id="prechatForm" align="middle">
<!-- Detail inputs -->
    
    Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactLastName" required="required"/><br /><br />
    Email &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactEmail" required="required"/><br /><br />
    Phone &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:contactPhone" /><br /><br />
    Subject &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="liveagent.prechat:caseSubject" /><br /><br />
  
<input type="hidden" name="liveagent.prechat.buttons" value="true" />

<!-- Map the detail inputs to the Contact fields --> 
<input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="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;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Email,true;" />

<!-- If the Contact is not found, then create one with the following fields set -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Contact" value="LastName,true;Email,true;" />

<!-- Save the Contact on the Live Chat Transcript's Contact Loookup -->
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Contact" value="Contact" />

<!-- Show the Contact when it is found or created -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />

<!-- Create a Case every time -->
<input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat" />
<input type="hidden" name="liveagent.prechat:caseRecordType" value="Live Chat" />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseOrigin;Subject,caseSubject;RecordType,caseRecordType;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;Subject,true;RecordType,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 Contact to the Case -->
<input type= "hidden" name="liveagent.prechat.findorcreate.linkToEntity:Contact" value="Case,ContactId" />

<input type="submit" value="Start Chat" id="prechat_submit"/> 

</form> 
</div>
</body>
</html>

Thanks
Mohan.

 

Hi,

    i am using following code when i used it means it showing  an error message connection lost please check your connection, actually i created a my system admin as live agent when he login also it showing an error can any one help me.


MY CODE:::::::::

<html>
<head>
<title>
My title
</title>

<script type='text/javascript' src='https://c.la2c1.salesforceliveagent.com/content/g/deployment.js'></script>
</head>
<body>
Welcome to Live Agent

<a id="liveagent_button_online_573E0000000Ccuh" href="javascript&colon;//Chat" style="display: block;" onclick="liveagent.startChat('573E0000000Ccuh')"> Start live agent</a>

<script type='text/javascript'>
liveagent.init('https://d.la2c1.salesforceliveagent.com/chat', '572i0000000Qr3I', '00Di0000000d7eN');
</script>
<img id="liveagent_button_online_573i0000000Qskn" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('573i0000000Qskn')" src="https://esoftcenter-developer-edition.na15.force.com/resource/1377010559000/onlineimage" /><img id="liveagent_button_offline_573i0000000Qskn" style="display: none; border: 0px none; " src="https://esoftcenter-developer-edition.na15.force.com/resource/1377010588000/offlineimage" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573i0000000Qskn', document.getElementById('liveagent_button_online_573i0000000Qskn'));
liveagent.showWhenOffline('573i0000000Qskn', document.getElementById('liveagent_button_offline_573i0000000Qskn'));
});</script>

</body>
</html>