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
iSfdciSfdc 

Trigger not working in bulk mode

Hi,
I am writing  a simple trigger, to replace 3 blank lines with 1 in the Description field.This Trigger is working fine in the Browser but not through Data Loader.Any Pointers on this.
 
Code:
trigger deletelines on Case (before insert,before update) {
  for(Case objCase:Trigger.new){
     if(objCase.RecordtypeId=='012200000004ajC'){          
        objCase.Description=objCase.Description.replace('\r\n\r\n\r\n','\r\n');
     }  
  }
}
 
 
 
 
Gani
jrotensteinjrotenstein
It might be that the DataLoader does not store blank lines as \r\n, so it would be worth looking at the actual values stored in the object.

Have you tried putting in some Debug code to see whether the IF statement is being correctly evaluated, and whether there is a \r\n sequence in the string?
SuperfellSuperfell
For API requests, you'll never see \r\n because XML parsers are required to normalize line endings to \n
iSfdciSfdc

Hi,

You are right the API is not recognising \r. I tried only with \n its working fine using Data loader, but not through browser.

Thanks

Gani

 

SuperfellSuperfell
right, you'll have to apply both of them.