-
Test Class for Inbound Email Service
I have written following inbound email service for lead object
global class LeadServices implements Messaging.InboundEmailHandler
{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
{
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
string emailbody = email.plaintextbody;
string emailsubject = email.subject;
string subToCompare = emailsubject.Substring(emailsubject.indexof('ref :') + 5).trim();
try
{
lead l = [SELECT Id, Name,Email FROM lead WHERE id = : subToCompare];
Task newTask = new Task();newTask.Description = emailbody;
newTask.Priority = 'Normal';
newTask.Status = 'Inbound Email';
newTask.Subject = emailsubject;
newTask.IsReminderSet = true;
newTask.ReminderDateTime = System.now();
newTask.WhoId = l.Id;
Insert newTask;
}
catch(QueryException e)
{
System.debug('Issue: ' + e);
}
result.success = true;
return result;
}
}
I am have having 55% code coverage now.
Can someone please hepl me with test class for this?-
This discussion was modified 6 years, 2 months ago by
Prachi.
-
This discussion was modified 6 years, 2 months ago by
Log In to reply.
Popular Salesforce Blogs
A Guide to Utilizing the Salesforce Customer Portal in Academia
Educational institutions have undergone significant changes over the years. Entering the early 2000s, these institutions gradually embraced technology by introducing advanced computer labs that allowed…
Global Crisis Readiness Guide: Optimize Operating Costs With Salesforce
While working on 2024 strategies for their companies, the top management must recognize the risk of another global recession shaking the global economy. Crisis-related risk…
Popular Salesforce Videos
Approval Process In Salesforce | Salesforce Development Tutorial
Approval process in Salesforce. This video will cover the following points - 1. Approval Process Learn how to create an approval process. 2. Manage Approval…
Develop Lightning Web Components Faster with Local Development Server | Developer Quick Takes
The Local Development Server is a Salesforce CLI plug-in that configures and runs a Lightning Web Components-enabled server on your computer. You can develop Lightning…
10 Example Future Method with Test Class | Asynchronous Apex | Salesforce Development Training Video
Salesforce uses a queue-based framework to handle asynchronous processes from such sources as future methods and batch Apex. This queue is used to balance request workload across…