You need to sign in to do that
Don't have an account?
fiona gentry
Apex Trigger test class Showing Stack Trace
Dear folks,
Wrote the test class for Trigger test class ,can't see the coverage ,can someone review the class and suggest the fix
Error i get is
Class.PrepaidEmailSubjectAswTest.PrepaidEmailSubjectAswTest: line 7, column 1
this apex trigger solution shows how to parse out an Email Subject in email-to-case using RegEx and search for
target word "Airtel"(case insensitive and exact match only )
Your help is appreciated
Regards
Fiona
Wrote the test class for Trigger test class ,can't see the coverage ,can someone review the class and suggest the fix
Error i get is
Class.PrepaidEmailSubjectAswTest.PrepaidEmailSubjectAswTest: line 7, column 1
@isTest private with sharing class PrepaidEmailSubjectAswTest { testmethod static void ert_PrepaidEmailSubjectAswTest(){ Test.starttest(); Id RecordTypeIdCase = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Executive Response').getRecordTypeId(); Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email',RecordTypeId = RecordTypeIdCase,Subject = 'Airtel'); insert cas; Test.stoptest(); } }Here is the Trigger apex which has label EmailSubjectAsw and the label has value 'Airtel',
this apex trigger solution shows how to parse out an Email Subject in email-to-case using RegEx and search for
target word "Airtel"(case insensitive and exact match only )
trigger PrepaidEmailSubjectAsw on Case (before insert) { String searchWords; List<String> strings; List<Group> lstPre = [SELECT Id from Group where Type = 'Queue' AND DeveloperNAME = 'Prepaid_Queue' LIMIT 1]; id rtid = Schema.Sobjecttype.Case.getRecordTypeInfosByName().get('Executive Rep').getRecordTypeId(); if(Trigger.isbefore && Trigger.IsInsert){ for (Case c : Trigger.new) { searchWords = Label.EmailSubjectAsw; strings = searchWords.split(','); if(c.Subject!=Null && c.RecordTypeId==rtid && lstPre.size() > 0){ if (isStringInTarget(strings, c.Subject)) { c.OwnerId =lstPre[0].id; } } } } public static Boolean isStringInTarget(List<String> strings, String target) { String strRegEx = '(?i)\\b('; for (String s : strings) { strRegEx = strRegEx + s + '|'; } strRegEx = strRegEx.removeEnd('|'); strRegEx = strRegEx + ')\\b'; Matcher matcher=Pattern.compile(strRegEx).matcher(target); Boolean result= matcher.find(); return result; } }
Your help is appreciated
Regards
Fiona
Try Below Code You Were Using Account To Get RecordType For Case Please Mark it As Best Answer If it Helps
Thank You!
All Answers
Try Below Code You Were Using Account To Get RecordType For Case Please Mark it As Best Answer If it Helps
Thank You!
Please follow below code
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh