Skip to content

Instantly share code, notes, and snippets.

@Sunil02kumar
Created August 3, 2023 10:16
Show Gist options
  • Save Sunil02kumar/eb56c3d80c93e68156330be600586b21 to your computer and use it in GitHub Desktop.
Save Sunil02kumar/eb56c3d80c93e68156330be600586b21 to your computer and use it in GitHub Desktop.
Remove special characters from file names when uploaded in salesforce
//purpose- remove special characters from file names when uploaded in salesforce
trigger SK_ContentVersionTrigger on ContentVersion (before insert) {
for(ContentVersion cv: trigger.new){
if(string.isNotBlank(cv.Title)){
cv.Title= cv.Title.replaceAll('[^-a-zA-Z0-9\\s+]', '');
System.debug('***updated Title '+cv.Title);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment