You need to sign in to do that
Don't have an account?

I need to remove Special characters and display string
Hi all,
I don't want to display special character in a field.
suppose i have one field in that field values are : A & B
But I need output A and B like this.
I created a class but it's not working Please help me.
public class CommonFunctions {
public void RemovingSpecialCharacters(){
List<case> listcase = new List<case>();
String specialCharacters = '&';
if(listcase.Notes__c.Contains('/&')){
listcase.Notes__c = 'And';
}
}
}
I don't want to display special character in a field.
suppose i have one field in that field values are : A & B
But I need output A and B like this.
I created a class but it's not working Please help me.
public class CommonFunctions {
public void RemovingSpecialCharacters(){
List<case> listcase = new List<case>();
String specialCharacters = '&';
if(listcase.Notes__c.Contains('/&')){
listcase.Notes__c = 'And';
}
}
}
can you tell me the line number from which you are getting error .
Please check below code in console it is working .
Thanks
Manoj
All Answers
You need to remove only & with And ?
I need to Remove & after i need to add AND.
Thanks
Try with below code it will help ,
I have used replace method of string class ,which takes two parameter first once which wnat to replace second one which you wnat to replace with .
Let me know any issue
Thnaks
Manoj
Initial term of field expression must be a concrete SObject: List<Case>
public class CommonFunctions {
public void RemovingSpecialCharacters(){
List<case> listcase = new List<case>();
if(string.valueOf(listcase.Notes__c).Contains('&')){
listcase.Notes__c = string.valueOf(listcase.Notes__c).replace('&','And');
}
}
}
I am getting same above error.
Thanks
can you tell me the line number from which you are getting error .
Please check below code in console it is working .
Thanks
Manoj
LIST<Case> caseLIST = [select ID, Description from Case LIMIT 1];
caseLIST[0].Description = string.valueOf(caseLIST[0].Description).replace('&', 'And');
system.debug(caseLIST);
Hi Manoj,
I tried the below code.
public class CommonFunctions {
public void RemovingSpecialCharacters(){
List<case> listcase = new List<case>();
if(listcase.Notes__c.Contains('&')){
listcase.Notes__c.replace('&','And');
} } }
I'm getting error "variable not found"
any solution