You need to sign in to do that
Don't have an account?
Help with EndWith or Substring
Dear all,
I am Struggling to find how to search the end of an email in my Apex Class.
I wrote this but it doesn't work somebody helps me?
//error message if non amcor email in Contact list
Integer i = con.email.length();
if (con.email.substring(con.email,i - 10,10) != '@amcor.com'){
isDisabled = true;
apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.ERROR, 'You cannot send an email to this person. Email is external from Amcor domain');
apexpages.addmessage(msg);
System.debug('@@DEBUG non amcor email: '+con);
return null;
}
The error message I got is as follow :
Error: Event_Ext Compile Error: Method does not exist or incorrect signature: [String].substring(String, Integer, Integer)
Many thanks
I am Struggling to find how to search the end of an email in my Apex Class.
I wrote this but it doesn't work somebody helps me?
//error message if non amcor email in Contact list
Integer i = con.email.length();
if (con.email.substring(con.email,i - 10,10) != '@amcor.com'){
isDisabled = true;
apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.ERROR, 'You cannot send an email to this person. Email is external from Amcor domain');
apexpages.addmessage(msg);
System.debug('@@DEBUG non amcor email: '+con);
return null;
}
The error message I got is as follow :
Error: Event_Ext Compile Error: Method does not exist or incorrect signature: [String].substring(String, Integer, Integer)
Many thanks
More String methods and documentation here: http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_string.htm
All Answers
Try this:
if (con.email.substring(i - 10,10) != '@amcor.com'){
More String methods and documentation here: http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_string.htm
How do you write the EndsWith function if it is different from Amcor.com?
Thank you so much for your help and really good support, my issue is solved now :)
What an excellent team!!!
Have a nice day.