You need to sign in to do that
Don't have an account?
sfdcIs
converting sObject to string
I am trying to convert this contact sObject to a string to grab the first 5 characters of the zip and compare but keep getting an error of "method does not exist or incorrect signature. any ideas?
String bpc= String.valueOf(c.MailingPostalCode);
if(bpc.left(5)>= cList.get(i).zip)
{
// more processing
}
to convert a string of type number to Integer.. you should use Integer.valueOf
String bpc= String.valueOf(c.MailingPostalCode);
if(integer.valueOf(bpc.substring(0,5))>= cList.get(i).zip)
{
// more processing
}
All Answers
String method left is available in winter 13... I think the instance that you are working has not been upgraded to new version yet.
Check this link for winter 13 upgrade on your instance.
http://trust.salesforce.com/trust/maintenance/
Ok thank you so there is no way we can manipulate this until the new release comes out?
you can use other methods...
use bpc.substring(0,5) instead of bpc.left(5).
ok i am getting very close now . The code compiled successfully. however, I realzied that the number comparison will not work since it's a string literal. need to grab the first 5 characters then compare it as a number with 5 characters
String bpc= String.valueOf(c.MailingPostalCode);
if(bpc.substring(0,5)>= cList.get(i).zip)
{
// more processing
}
to convert a string of type number to Integer.. you should use Integer.valueOf
String bpc= String.valueOf(c.MailingPostalCode);
if(integer.valueOf(bpc.substring(0,5))>= cList.get(i).zip)
{
// more processing
}