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

How to remove spaces in a text field before update, before insert,after insert?

Sai PraveenSai Praveen (Salesforce Developers) 

You can just use the below line in the trigger in for loop of as below.
FieldAPINAME.replaceAll( '\\s+', '');

trigger acctrigger on Account (before insert,before update) {   
    for(Account acc:{   
        '\\s+', '');


Let me know if you face any issues.

If this solution helps, Please mark it as best answer.