Created
August 3, 2023 10:16
-
-
Save Sunil02kumar/eb56c3d80c93e68156330be600586b21 to your computer and use it in GitHub Desktop.
Remove special characters from file names when uploaded in salesforce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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