You need to sign in to do that
Don't have an account?
magsy1.3942130065717605E12
How to remove single quote from end of string using escapeSingleQuotes
Hi,
I am new to Salesforce and therefore want to know the exact functioning of escapeSingleQuotes() method.
My code uses this method as:
soql = 'Select Id, Name, Metals__c from Smelter__c where';
soql += ' Name LIKE \''+String.escapeSingleQuotes(smelterNameQuery.trim())+'%\'';
The name consists of single quote at the end of string.
So how do I remove the single quote.?
I am new to Salesforce and therefore want to know the exact functioning of escapeSingleQuotes() method.
My code uses this method as:
soql = 'Select Id, Name, Metals__c from Smelter__c where';
soql += ' Name LIKE \''+String.escapeSingleQuotes(smelterNameQuery.trim())+'%\'';
The name consists of single quote at the end of string.
So how do I remove the single quote.?
Here is the Sample code which you can use to remove the ',' if there is any at the end of your string.
================================================
string teststring = 'Myteststring,' ;
if(teststring.endsWith(','))
{teststring= teststring.substring(0,teststring.length()-1);
system.debug('>>>>>>>>>>' + teststring);
}
=================================================
Also, you can review the String methods at http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_string.htm
Please Mark it as the ""Best Answer"" if it works for you.
Thanks.
Chaten Raghav