-
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 4 years, 4 months ago by Prachi.
Log In to reply.
Popular Salesforce Blogs
Salesforce Duplicate Management: Dirty Data Handled Well!
If you have dirty data, your Salesforce Cadillac has the potential to bring your entire organization to a screeching halt. Fabricating business decisions based on…
Highlights of Salesforce and Alibaba collaboration
Salesforce and Alibaba Cloud have confirmed that they are working on a deal to build Salesforce Social Commerce, a headless commerce platform that will be…
Forceea: The Enterprise Data Factory We've Been Waiting For | Salesforce
Introduction Everybody needs testing records of SObjects: Developers need testing data for their unit tests. Testers need data for testing. Administrators and architects need data…
Popular Salesforce Videos
Automate Simple Business Processes with Process Builder | Salesforce Trailhead
In this video, we working on the Trailhead challenge Lightning Flow unit Automate Simple Business Processes with Process Builder where a lot of trailblazers face…
AMPscript Case Functions - Salesforce Marketing Cloud Functions in 5 minutes
Cameron Robert steps through how to use the Upper, Lower and Proper Case Functions in AMPscript. Cameron also takes a closer look at the ProperCase…
Salesforce Announces New Salesforce CDP Updates | Salesforce CDP
Salesforce, one of the largest global providers of CRM solutions, launched Salesforce CDP last year. Salesforce Customer Data Platform is an enterprise customer data platform…