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
JeffroJeffro 

Apostrophe translated to '

I am using Salesforce's email services to populate a Contact record with information submitted through a web form. A user fills out the web form, all of the information from the form is sent as an email, the Apex class parses the email, and populates the Contact record.

The problem I have is that I have picklist values on the form that have an apostrophe(') in them. They are "Bachelor's" and "Master's" . When the email class parses the information, the field on the Salesforce side is populated with"Bachelor's" or"Master's". Here is the Apex code that parses that line:

 

contact.Highest_Degree_Earned__c = getFieldValue(myPlainText,'Education:');

 

How can I account for a value returned with an apostrophe? This seemed to just started happening when we were upgraded to Spring 09 release.

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
jrotensteinjrotenstein

You could try something like:

 

contact.Highest_Degree_Earned__c = getFieldValue(myPlainText,'Education:').replace(''','\'');

 

Message Edited by jrotenstein on 02-19-2009 11:50 AM

All Answers

jrotensteinjrotenstein

You could try something like:

 

contact.Highest_Degree_Earned__c = getFieldValue(myPlainText,'Education:').replace(''','\'');

 

Message Edited by jrotenstein on 02-19-2009 11:50 AM
This was selected as the best answer
JeffroJeffro
Thanks! That worked.
Stephen EricStephen Eric
how about if am doing a mouse over lookup with a dropdown. i tried to replace the lookup controller with your fix and it didnt work. this is the lookup controller. where should this replace code go to? the callername is the field producing the error.



public with sharing class LookupController {

    public BMCServiceDesk__Incident__c inc {get; set;}
    public String accountName {get; set;}
    public Id accountId {get; set;}
    public String callerName {get; set;}
    public Id callerId {get; set;}
    public List<User> users {get;set;}
    public List<User> callers {get; set;}
    ApexPages.StandardController GstdController;

    public LookupController(ApexPages.StandardController controller) {
        GstdController = controller;
        this.inc = (BMCServiceDesk__Incident__c)GstdController.getRecord();
        this.users = [Select Id, Name from User where Id = :inc.BMCServiceDesk__FKClient__c];
        this.callers = [Select Id, Name from User where Id = :inc.FKUser1__c];
        if (users.size() > 0)
        {
            this.accountName = users[0].Name;
            this.accountId = users[0].Id;
        }
        if (callers.size() > 0)
        {
            this.callerName = (callers[0].Name.replace('&#039;','\''));
            this.callerId = callers[0].Id;
        }
    }    
    
    public PageReference mysave()
    {
        if (accountName == '' || accountName == null || inc.BMCServiceDesk__FKClient__c == null)
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please enter a value in the Client Name field.'));

            return null;
        }   
        else
        {
            pageReference ps = GstdController.save();
            pageReference pv = GstdController.view();
            
            return pv;
        }

    }



}