function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
faceroy123faceroy123 

Test Class for Regex trigger

Hi,

 

would anyone be able to assist me in writing a test class for a regex trigger:

 

It searches the subject field on a case and updates a field if it finds a match.

 

Thanks

 

rigger Case_ConsNumber1 on Case (before update) {
    
    for(Case c:Trigger.new)
      if(c.subject!=null && c.Tracking_Job_Number__c == null) {  
string subject = c.subject;
Pattern p = Pattern.compile('[A-Z]{2}\\d{6}|[a-z]{2}\\d{6}]|[A-Z]{3}\\d{5}|[a-z]{3}\\d{5}]');
Matcher m = p.matcher(c.subject);

if (m.find()) 
{
 if (c.origin=='Email'){
  c.Tracking_Job_Number__c=(m.group(0));
 


}}}}