+ Start a Discussion
anjaanja 

standardize input of address

is there a solution out there to convert Street to St., and Saint to St. as a user enters address information? Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

try this trigger

 

trigger updateprimaryStreet on Contact(before insert, befoe update)
{
 
 
for(contact con : trigger.new)
{
     if(con.Contact_Primary_Street__c != null)
        {
                 con.Contact_Primary_Street__c = String.valueOf(con.Contact_Primary_Street__c).replace('Street' , 'St.');
                 con.Contact_Primary_Street__c = String.valueOf(con.Contact_Primary_Street__c).replace('Saint' , 'St.');
        }
}
 
 
}

 

All Answers

Shashikant SharmaShashikant Sharma

You can do thisby

1) workflow

2) before insert , before update trigger 

 

If you can provide me some more info about your object name, field name and req , I can help you creating a workflow or trigger to solve your issue.

anjaanja

Great! for example in Contact there is a custom field Contact_Primary_Street__c. The difficulty is that for street and saint we would like to standardize that the input is always St. Ex: 5721 Saint Martens Street would become 5721 St. Martens St.

 

Also would be useful for Account name. Ex: Saint Martens Hospital to become St. Martens Hospital; & to and, Med to Medical; etc.

 

The goal to standarize naming as much as possible.

Shashikant SharmaShashikant Sharma

try this trigger

 

trigger updateprimaryStreet on Contact(before insert, befoe update)
{
 
 
for(contact con : trigger.new)
{
     if(con.Contact_Primary_Street__c != null)
        {
                 con.Contact_Primary_Street__c = String.valueOf(con.Contact_Primary_Street__c).replace('Street' , 'St.');
                 con.Contact_Primary_Street__c = String.valueOf(con.Contact_Primary_Street__c).replace('Saint' , 'St.');
        }
}
 
 
}

 

This was selected as the best answer
anjaanja

Works like a charm!

Shashikant SharmaShashikant Sharma

Gr8, Please mark this as Accepted solution , so that it can benifit others as well.