You need to sign in to do that
Don't have an account?
cactusdave
Parsing/Substring Value in Apex Trigger - Looking for Specific value "@"
I am looking to parse the email address from the user table to get the first part of the address. For example, if an email address is bgates@microsoft.com, I want to just get the bgates. I can use substring to get the first part but don't know what value to put in where this would end.
If this was in Excel, I would do the following =mid(email, 0, find(@)-1)
Is there a similar way in which I could utilize the find() functionality in excel and apply this in the trigger? Thanks.
Use the indexOf function to find the @ symbol, and then use that as the second integer.
All Answers
Use the indexOf function to find the @ symbol, and then use that as the second integer.
This worked. I added the following and was able to get the value I wanted from the user object:
// Parse Email to get all of the values prior to the "@" sign
User caseowneruserinfor = [select email from User where id = :caseowner];
string CreatorName;
integer Whereitsat;
CreatorName = caseowneruserinfor.email;
Whereitsat = CreatorName.indexOf(
a.CaseCreatorName__c = CreatorName.substring(0,Whereitsat) ;
I wrote a piece of apex code to parse through the body of an email and look for an email address. Here's how i pulled the email address from the body of the message.